Ignore:
Timestamp:
2017-12-17T00:17:20+01:00 (3 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/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r12620 r13204  
    55
    66import java.io.File;
    7 import java.io.FileInputStream;
    87import java.io.IOException;
    98import java.io.InputStream;
    109import java.lang.reflect.Constructor;
    1110import java.net.URL;
     11import java.nio.file.Files;
     12import java.nio.file.InvalidPathException;
    1213import java.text.MessageFormat;
    1314import java.util.ArrayList;
     
    114115        this.file = file;
    115116        try (
    116             FileInputStream fis = new FileInputStream(file);
     117            InputStream fis = Files.newInputStream(file.toPath());
    117118            JarInputStream jar = new JarInputStream(fis)
    118119        ) {
     
    122123            scanManifest(manifest, false);
    123124            libraries.add(0, Utils.fileToURL(file));
    124         } catch (IOException e) {
     125        } catch (IOException | InvalidPathException e) {
    125126            throw new PluginException(name, e);
    126127        }
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r12620 r13204  
    55
    66import java.io.File;
    7 import java.io.FileInputStream;
    87import java.io.FilenameFilter;
    98import java.io.IOException;
     9import java.io.InputStream;
     10import java.nio.file.Files;
     11import java.nio.file.InvalidPathException;
    1012import java.util.ArrayList;
    1113import java.util.Collection;
     
    145147
    146148    protected void processLocalPluginInformationFile(File file) throws PluginListParseException {
    147         try (FileInputStream fin = new FileInputStream(file)) {
     149        try (InputStream fin = Files.newInputStream(file.toPath())) {
    148150            List<PluginInformation> pis = new PluginListParser().parse(fin);
    149151            for (PluginInformation pi : pis) {
     
    154156                availablePlugins.put(pi.name, pi);
    155157            }
    156         } catch (IOException e) {
     158        } catch (IOException | InvalidPathException e) {
    157159            throw new PluginListParseException(e);
    158160        }
Note: See TracChangeset for help on using the changeset viewer.