Ignore:
Timestamp:
2017-12-17T00:17:20+01:00 (2 years ago)
Author:
Don-vip
Message:

enable new PMD rule AvoidFileStream - see https://pmd.github.io/pmd-6.0.0/pmd_rules_java_performance.html#avoidfilestream / https://bugs.openjdk.java.net/browse/JDK-8080225 for details

Location:
trunk/src/org/openstreetmap/josm/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java

    r12856 r13204  
    33
    44import java.io.File;
    5 import java.io.FileOutputStream;
    65import java.io.IOException;
     6import java.nio.channels.FileChannel;
    77import java.nio.channels.FileLock;
     8import java.nio.file.StandardOpenOption;
    89import java.util.Arrays;
    910import java.util.Properties;
     
    110111            Logging.warn("Cannot create cache dir lock file");
    111112        }
    112         cacheDirLock = new FileOutputStream(cacheDirLockPath).getChannel().tryLock();
     113        cacheDirLock = FileChannel.open(cacheDirLockPath.toPath(), StandardOpenOption.WRITE).tryLock();
    113114
    114115        if (cacheDirLock == null)
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java

    r12868 r13204  
    33
    44import java.io.File;
    5 import java.io.FileInputStream;
    6 import java.io.FileNotFoundException;
     5import java.io.IOException;
    76import java.io.InputStream;
     7import java.nio.file.Files;
     8import java.nio.file.InvalidPathException;
    89import java.util.Arrays;
    910import java.util.Collections;
     
    6364        if (grid != null) {
    6465            try {
    65                 return new FileInputStream(grid.getAbsoluteFile());
    66             } catch (FileNotFoundException ex) {
    67                 Logging.warn("NTV2 grid shift file not found: " + grid);
    68                 Logging.trace(ex);
     66                return Files.newInputStream(grid.getAbsoluteFile().toPath());
     67            } catch (IOException | InvalidPathException ex) {
     68                Logging.warn("Unable to open NTV2 grid shift file: " + grid);
     69                Logging.debug(ex);
    6970            }
    7071        }
Note: See TracChangeset for help on using the changeset viewer.