- Timestamp:
- 2013-09-27T19:50:29+02:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/ServerSidePreferences.java
r6248 r6268 64 64 BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream())); 65 65 StringBuilder b = new StringBuilder(); 66 for (String line = reader.readLine(); line != null; line = reader.readLine()) { 67 b.append(line); 68 b.append("\n"); 66 try { 67 for (String line = reader.readLine(); line != null; line = reader.readLine()) { 68 b.append(line); 69 b.append("\n"); 70 } 71 } finally { 72 reader.close(); 69 73 } 70 74 if (con instanceof HttpURLConnection) { … … 73 77 return b.toString(); 74 78 } catch (IOException e) { 79 Main.error(e); 75 80 e.printStackTrace(); 76 81 } -
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r6248 r6268 33 33 import org.openstreetmap.josm.io.MirroredInputStream; 34 34 import org.openstreetmap.josm.tools.Pair; 35 import org.openstreetmap.josm.tools.Utils; 35 36 36 37 /** … … 125 126 private static void loadInits() { 126 127 Pattern epsgPattern = Pattern.compile("<(\\d+)>(.*)<>"); 128 BufferedReader r = null; 127 129 try { 128 130 InputStream in = new MirroredInputStream("resource://data/epsg"); 129 BufferedReaderr = new BufferedReader(new InputStreamReader(in));131 r = new BufferedReader(new InputStreamReader(in)); 130 132 String line, lastline = ""; 131 133 while ((line = r.readLine()) != null) { … … 144 146 } 145 147 } catch (IOException ex) { 146 throw new RuntimeException(); 148 throw new RuntimeException(ex); 149 } finally { 150 Utils.close(r); 147 151 } 148 152 } -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r6246 r6268 153 153 ignoredErrors.clear(); 154 154 if (Main.pref.getBoolean(ValidatorPreference.PREF_USE_IGNORE, true)) { 155 BufferedReader in = null; 155 156 try { 156 final BufferedReaderin = new BufferedReader(new FileReader(getValidatorDir() + "ignorederrors"));157 in = new BufferedReader(new FileReader(getValidatorDir() + "ignorederrors")); 157 158 for (String line = in.readLine(); line != null; line = in.readLine()) { 158 159 ignoredErrors.add(line); … … 162 163 } catch (final IOException e) { 163 164 e.printStackTrace(); 165 } finally { 166 Utils.close(in); 164 167 } 165 168 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r6265 r6268 62 62 import org.openstreetmap.josm.tools.GBC; 63 63 import org.openstreetmap.josm.tools.MultiMap; 64 import org.openstreetmap.josm.tools.Utils; 64 65 65 66 /** … … 205 206 return; 206 207 for (String source : sources.split(";")) { 208 BufferedReader reader = null; 207 209 try { 208 210 MirroredInputStream s = new MirroredInputStream(source); … … 213 215 r = new InputStreamReader(s); 214 216 } 215 BufferedReaderreader = new BufferedReader(r);217 reader = new BufferedReader(r); 216 218 217 219 String okValue = null; … … 272 274 } catch (IOException e) { 273 275 errorSources += source + "\n"; 276 } finally { 277 Utils.close(reader); 274 278 } 275 279 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r6248 r6268 674 674 txtSource.append(line + "\n"); 675 675 } 676 reader.close(); 676 677 } catch (IOException ex) { 677 678 txtSource.append("<ERROR: failed to read file!>"); -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r6248 r6268 212 212 213 213 protected String extractToken(HttpURLConnection connection) { 214 try { 215 BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream())); 214 BufferedReader r = null; 215 try { 216 r = new BufferedReader(new InputStreamReader(connection.getInputStream())); 216 217 String c; 217 218 Pattern p = Pattern.compile(".*authenticity_token.*value=\"([^\"]+)\".*"); 218 while ((c = r.readLine()) != null) {219 while ((c = r.readLine()) != null) { 219 220 Matcher m = p.matcher(c); 220 if (m.find())221 if (m.find()) { 221 222 return m.group(1); 223 } 222 224 } 223 225 } catch (IOException e) { 226 Main.error(e); 224 227 return null; 228 } finally { 229 Utils.close(r); 225 230 } 226 231 return null; -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r6248 r6268 621 621 if (requestBody != null) { 622 622 BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")); 623 bwr.write(requestBody); 624 bwr.flush(); 623 try { 624 bwr.write(requestBody); 625 bwr.flush(); 626 } finally { 627 bwr.close(); 628 } 625 629 } 626 630 Utils.close(out); … … 657 661 BufferedReader in = new BufferedReader(new InputStreamReader(i)); 658 662 String s; 659 while((s = in.readLine()) != null) { 660 responseBody.append(s); 661 responseBody.append("\n"); 663 try { 664 while((s = in.readLine()) != null) { 665 responseBody.append(s); 666 responseBody.append("\n"); 667 } 668 } finally { 669 in.close(); 662 670 } 663 671 } -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r6248 r6268 134 134 String line; 135 135 StringBuilder ba = new StringBuilder(); 136 while ((line = br.readLine()) != null) { 137 ba.append(line); 138 ba.append("\n"); 136 try { 137 while ((line = br.readLine()) != null) { 138 ba.append(line); 139 ba.append("\n"); 140 } 141 } finally { 142 br.close(); 139 143 } 140 144 String incomingData = ba.toString(); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6245 r6268 328 328 try { 329 329 c.close(); 330 } catch (IOException e) {331 // ignore330 } catch (IOException e) { 331 Main.warn(e); 332 332 } 333 333 } … … 342 342 try { 343 343 zip.close(); 344 } catch(IOException e) { 345 // ignore 346 } 347 } 348 349 private final static double EPSILION = 1e-11; 350 344 } catch (IOException e) { 345 Main.warn(e); 346 } 347 } 348 349 private final static double EPSILON = 1e-11; 350 351 /** 352 * Determines if the two given double values are equal (their delta being smaller than a fixed epsilon) 353 * @param a The first double value to compare 354 * @param b The second double value to compare 355 * @return {@code true} if {@code abs(a - b) <= 1e-11}, {@code false} otherwise 356 */ 351 357 public static boolean equalsEpsilon(double a, double b) { 352 return Math.abs(a - b) <= EPSIL ION;358 return Math.abs(a - b) <= EPSILON; 353 359 } 354 360 -
trunk/test/functional/org/openstreetmap/josm/gui/history/HistoryBrowserTest.java
r5556 r6268 6 6 import java.awt.BorderLayout; 7 7 import java.io.File; 8 import java.io.InputStream; 8 9 import java.text.MessageFormat; 9 10 import java.util.Properties; … … 37 38 // 38 39 try { 39 testProperties.load(HistoryBrowserTest.class.getResourceAsStream("/test-functional-env.properties")); 40 InputStream is = HistoryBrowserTest.class.getResourceAsStream("/test-functional-env.properties"); 41 testProperties.load(is); 42 is.close(); 40 43 } catch(Exception e){ 41 44 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties")); … … 83 86 } 84 87 88 /** 89 * Constructs a new {@code HistoryBrowserTest}. 90 */ 85 91 public HistoryBrowserTest(){ 86 92 build(); -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r5556 r6268 12 12 import java.io.FileWriter; 13 13 import java.io.IOException; 14 import java.io.InputStream; 14 15 import java.io.PrintWriter; 15 16 import java.text.MessageFormat; … … 138 139 // 139 140 try { 140 testProperties.load(MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties")); 141 InputStream is = MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties"); 142 testProperties.load(is); 143 is.close(); 141 144 } catch(Exception e){ 142 145 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties")); -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r5556 r6268 10 10 import java.io.FileWriter; 11 11 import java.io.IOException; 12 import java.io.InputStream; 12 13 import java.io.PrintWriter; 13 14 import java.text.MessageFormat; … … 145 146 // 146 147 try { 147 testProperties.load(MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties")); 148 InputStream is = MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties"); 149 testProperties.load(is); 150 is.close(); 148 151 } catch(Exception e){ 149 152 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
Note:
See TracChangeset
for help on using the changeset viewer.