Changeset 9799 in josm for trunk


Ignore:
Timestamp:
2016-02-14T20:49:43+01:00 (9 years ago)
Author:
stoecker
Message:

fix Coverity issues 1349911, 1349912, 1349913, 1349917, 1349918, 1349919, 1349922, 1349923

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r9768 r9799  
    293293        factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
    294294
    295         InputStream in = new CachedFile(baseUrl).
    296                 setHttpHeaders(headers).
     295        try (CachedFile cf = new CachedFile(baseUrl); InputStream in = cf.setHttpHeaders(headers).
    297296                setMaxAge(7 * CachedFile.DAYS).
    298297                setCachingStrategy(CachedFile.CachingStrategy.IfModifiedSince).
    299                 getInputStream();
    300         try {
     298                getInputStream()) {
    301299            byte[] data = Utils.readBytesFromStream(in);
    302300            if (data == null || data.length == 0) {
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r9597 r9799  
    269269    public static List<ProjectionDefinition> loadProjectionDefinitions(String path) throws IOException {
    270270        try (
    271             InputStream in = new CachedFile(path).getInputStream();
     271            CachedFile cf = new CachedFile(path);
     272            InputStream in = cf.getInputStream();
    272273            BufferedReader r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
    273274        ) {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r9371 r9799  
    719719                }
    720720            }
     721        } finally {
     722            cache.close();
    721723        }
    722724        return result;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r8958 r9799  
    5353        super.initialize();
    5454        if (ENGINE != null) {
    55             try (Reader reader = new InputStreamReader(
    56                     new CachedFile("resource://data/validator/opening_hours.js").getInputStream(), StandardCharsets.UTF_8)) {
     55            try (CachedFile cf = new CachedFile("resource://data/validator/opening_hours.js");
     56                 Reader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) {
    5757                ENGINE.eval(reader);
    5858                ENGINE.eval("var opening_hours = require('opening_hours');");
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r9744 r9799  
    166166        for (String source : Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES)) {
    167167            try (
    168                 InputStream s = new CachedFile(source).getInputStream();
     168                CachedFile cf = new CachedFile(source);
     169                InputStream s = cf.getInputStream();
    169170                BufferedReader reader = new BufferedReader(UTFInputStreamReader.create(s));
    170171            ) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r9400 r9799  
    324324            Main.warn(tr("Failed to load Mappaint styles from ''{0}''. Exception was: {1}", entry.url, e.toString()));
    325325            Main.error(e);
     326        } finally {
     327            if (cf != null) {
     328                cf.close();
     329            }
    326330        }
    327331        return null;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java

    r8958 r9799  
    323323            throws SAXException, IOException {
    324324        Collection<TaggingPreset> tp;
    325         CachedFile cf = new CachedFile(source).setHttpAccept(PRESET_MIME_TYPES);
    326325        try (
     326            CachedFile cf = new CachedFile(source).setHttpAccept(PRESET_MIME_TYPES);
    327327            // zip may be null, but Java 7 allows it: https://blogs.oracle.com/darcy/entry/project_coin_null_try_with
    328328            InputStream zip = cf.findZipEntryInputStream("xml", "preset")
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r9078 r9799  
    289289    public Iterable<Object> startWithValidation(final Reader in, String namespace, String schemaSource) throws SAXException {
    290290        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    291         try (InputStream mis = new CachedFile(schemaSource).getInputStream()) {
     291        try (CachedFile cf = new CachedFile(schemaSource); InputStream mis = cf.getInputStream()) {
    292292            Schema schema = factory.newSchema(new StreamSource(mis));
    293293            ValidatorHandler validator = schema.newValidatorHandler();
Note: See TracChangeset for help on using the changeset viewer.