Ignore:
Timestamp:
2015-05-02T00:55:19+02:00 (9 years ago)
Author:
Don-vip
Message:

fix potential NPEs and Sonar issues related to serialization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8304 r8308  
    378378            Main.warn("Unable to create directory "+out.getPath());
    379379        }
    380         for (File f : in.listFiles()) {
    381             File target = new File(out, f.getName());
    382             if (f.isDirectory()) {
    383                 copyDirectory(f, target);
    384             } else {
    385                 copyFile(f, target);
     380        File[] files = in.listFiles();
     381        if (files != null) {
     382            for (File f : files) {
     383                File target = new File(out, f.getName());
     384                if (f.isDirectory()) {
     385                    copyDirectory(f, target);
     386                } else {
     387                    copyFile(f, target);
     388                }
    386389            }
    387390        }
     
    415418        if( path.exists() ) {
    416419            File[] files = path.listFiles();
    417             for (File file : files) {
    418                 if (file.isDirectory()) {
    419                     deleteDirectory(file);
    420                 } else if (!file.delete()) {
    421                     Main.warn("Unable to delete file: "+file.getPath());
     420            if (files != null) {
     421                for (File file : files) {
     422                    if (file.isDirectory()) {
     423                        deleteDirectory(file);
     424                    } else if (!file.delete()) {
     425                        Main.warn("Unable to delete file: "+file.getPath());
     426                    }
    422427                }
    423428            }
Note: See TracChangeset for help on using the changeset viewer.