Changeset 5839 in josm for trunk


Ignore:
Timestamp:
2013-04-11T19:41:05+02:00 (7 years ago)
Author:
Don-vip
Message:

see #8570 - close more streams

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

Legend:

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

    r5819 r5839  
    4040            in = new BufferedReader(new InputStreamReader(resource.openStream(), "UTF-8"));
    4141            StringBuffer sb = new StringBuffer();
    42             for (String line = in.readLine(); line != null; line = in.readLine()) {
    43                 sb.append(line).append("\n");
     42            try {
     43                for (String line = in.readLine(); line != null; line = in.readLine()) {
     44                    sb.append(line).append("\n");
     45                }
     46            } finally {
     47                in.close();
    4448            }
    4549            s = sb.toString();
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r5792 r5839  
    323323                UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8");
    324324                String r = new Scanner(in).useDelimiter("\\A").next();
     325                in.close();
    325326                System.out.println("Successfully loaded Bing attribution data.");
    326327                return r.getBytes("utf-8");
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r5266 r5839  
    469469                return false;
    470470        }
    471         try
    472         {
    473             if(load(en.openStream(), tr.openStream(), false))
    474             {
     471        InputStream enStream = null;
     472        InputStream trStream = null;
     473        try {
     474            enStream = en.openStream();
     475            trStream = tr.openStream();
     476            if (load(enStream, trStream, false)) {
    475477                pluralMode = languages.get(l);
    476478                loadedCode = l;
    477479                return true;
    478480            }
    479         }
    480         catch(IOException e)
    481         {
     481        } catch(IOException e) {
     482            // Ignore exception
     483        } finally {
     484            if (trStream != null) try {trStream.close();} catch(IOException e) {}
     485            if (enStream != null) try {enStream.close();} catch(IOException e) {}
    482486        }
    483487        return false;
Note: See TracChangeset for help on using the changeset viewer.