Ignore:
Timestamp:
2016-12-14T16:13:11+01:00 (4 years ago)
Author:
Don-vip
Message:

sonar - squid:S2095 - Resources should be closed

File:
1 edited

Legend:

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

    r11374 r11399  
    904904     */
    905905    private static ImageResource getIfAvailableHttp(String url, ImageType type) {
    906         CachedFile cf = new CachedFile(url)
    907                 .setDestDir(new File(Main.pref.getCacheDirectory(), "images").getPath());
    908         try (InputStream is = cf.getInputStream()) {
     906        try (CachedFile cf = new CachedFile(url).setDestDir(new File(Main.pref.getCacheDirectory(), "images").getPath());
     907             InputStream is = cf.getInputStream()) {
    909908            switch (type) {
    910909            case SVG:
     
    924923                return img == null ? null : new ImageResource(img);
    925924            default:
    926                 throw new AssertionError();
     925                throw new AssertionError("Unsupported type: " + type);
    927926            }
    928927        } catch (IOException e) {
    929928            Main.debug(e);
    930929            return null;
    931         } finally {
    932             cf.close();
    933930        }
    934931    }
     
    12261223            parser.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(new byte[0])));
    12271224
    1228             CachedFile cf = new CachedFile(base + fn).setDestDir(
    1229                     new File(Main.pref.getUserDataDirectory(), "images").getPath());
    1230             try (InputStream is = cf.getInputStream()) {
     1225            try (CachedFile cf = new CachedFile(base + fn).setDestDir(new File(Main.pref.getUserDataDirectory(), "images").getPath());
     1226                 InputStream is = cf.getInputStream()) {
    12311227                parser.parse(new InputSource(is));
    12321228            }
    1233             cf.close();
    12341229        } catch (SAXReturnException r) {
    12351230            Main.trace(r);
Note: See TracChangeset for help on using the changeset viewer.