Changeset 11553 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2017-02-12T16:32:18+01:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r11397 r11553 15 15 import java.util.Collection; 16 16 import java.util.Date; 17 import java.util.Optional; 17 18 import java.util.TreeSet; 18 19 import java.util.regex.Matcher; … … 362 363 public static String explainGenericOsmApiException(OsmApiException e) { 363 364 Main.error(e); 364 String errMsg = e.getErrorHeader();365 if (errMsg == null) {366 errMsg = e.getErrorBody();367 }368 if (errMsg == null) {369 errMsg = tr("no error message available");370 }371 365 return tr("<html>" 372 366 + "Communication with the OSM server ''{0}''failed. The server replied<br>" … … 377 371 getUrlFromException(e), 378 372 e.getResponseCode(), 379 errMsg 373 Optional.ofNullable(Optional.ofNullable(e.getErrorHeader()).orElseGet(e::getErrorBody)) 374 .orElse(tr("no error message available")) 380 375 ); 381 376 } -
trunk/src/org/openstreetmap/josm/tools/HttpClient.java
r11535 r11553 19 19 import java.util.Map; 20 20 import java.util.Map.Entry; 21 import java.util.Optional; 21 22 import java.util.Scanner; 22 23 import java.util.TreeMap; … … 148 149 if (redirectLocation == null) { 149 150 /* I18n: argument is HTTP response code */ 150 String msg = tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." + 151 " Can''t redirect. Aborting.", connection.getResponseCode()); 152 throw new IOException(msg); 151 throw new IOException(tr("Unexpected response from HTTP server. Got {0} response without ''Location'' header." + 152 " Can''t redirect. Aborting.", connection.getResponseCode())); 153 153 } else if (maxRedirects > 0) { 154 154 url = new URL(url, redirectLocation); … … 284 284 } catch (IOException ioe) { 285 285 Main.debug(ioe); 286 in = connection.getErrorStream(); 287 if (in == null) { 288 in = new ByteArrayInputStream(new byte[]{}); 289 } 286 in = Optional.ofNullable(connection.getErrorStream()).orElseGet(() -> new ByteArrayInputStream(new byte[]{})); 290 287 } 291 288 in = new ProgressInputStream(in, getContentLength(), monitor); -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r11454 r11553 384 384 385 385 private static int getGroupModifier(int group) { 386 Integer m = groups.get(group); 387 if (m == null) 388 m = -1; 389 return m; 386 return Optional.ofNullable(groups.get(group)).orElse(-1); 390 387 } 391 388
Note:
See TracChangeset
for help on using the changeset viewer.