- Timestamp:
- 2018-09-22T12:38:49+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java
r13439 r14270 7 7 import java.util.Map; 8 8 import java.util.Map.Entry; 9 import java.util.Optional; 9 10 import java.util.Set; 10 11 import java.util.concurrent.ConcurrentHashMap; … … 29 30 private static final String HTTP_RESPONSE_CODE = "httpResponseCode"; 30 31 private static final String ERROR_MESSAGE = "errorMessage"; 32 private static final String EXCEPTION = "exception"; 31 33 // this contains all of the above 32 34 private static final Set<String> RESERVED_KEYS = new HashSet<>(Arrays.asList( … … 36 38 EXPIRATION_TIME, 37 39 HTTP_RESPONSE_CODE, 38 ERROR_MESSAGE 40 ERROR_MESSAGE, 41 EXCEPTION 39 42 )); 40 43 … … 195 198 attrs.put(ERROR_MESSAGE, message); 196 199 } 200 201 /** 202 * @param e exception that caused error 203 * 204 */ 205 public void setException(Exception e) { 206 attrs.put(EXCEPTION, e.getClass().getCanonicalName()); 207 } 208 209 /** 210 * @return Optional exception that was thrown when fetching resource 211 * 212 */ 213 public Optional<Class<? extends Exception>> getException() { 214 String className = attrs.get(EXCEPTION); 215 if (className == null) { 216 return Optional.empty(); 217 } 218 try { 219 Class<?> klass = Class.forName(className); 220 if (Exception.class.isAssignableFrom(klass)) { 221 return Optional.of(klass.asSubclass(Exception.class)); 222 } 223 } catch (ClassNotFoundException | ClassCastException ex) { 224 // NOOP 225 } 226 return Optional.empty(); 227 } 197 228 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r13825 r14270 392 392 attributes.setResponseCode(404); 393 393 attributes.setError(e); 394 attributes.setException(e); 394 395 boolean doCache = isResponseLoadable(null, 404, null) || cacheAsEmpty(); 395 396 if (doCache) { … … 404 405 } else { 405 406 attributes.setError(e); 407 attributes.setException(e); 406 408 attributes.setResponseCode(599); // set dummy error code, greater than 500 so it will be not cached 407 409 return false; … … 410 412 } catch (InterruptedException e) { 411 413 attributes.setError(e); 414 attributes.setException(e); 412 415 Logging.logWithStackTrace(Logging.LEVEL_WARN, e, "JCS - Exception during download {0}", getUrlNoException()); 413 416 Thread.currentThread().interrupt(); -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r14268 r14270 6 6 import java.io.ByteArrayInputStream; 7 7 import java.io.IOException; 8 import java.net.SocketTimeoutException; 8 9 import java.net.URL; 9 10 import java.nio.charset.StandardCharsets; … … 226 227 tile.setLoaded(false); // treat 500 errors as temporary and try to load it again 227 228 } 229 // treat SocketTimeoutException as transient error 230 attributes.getException() 231 .filter(x -> x.isAssignableFrom(SocketTimeoutException.class)) 232 .ifPresent(x -> tile.setLoaded(false)); 228 233 } else { 229 234 tile.setError(tr("Problem loading tile"));
Note:
See TracChangeset
for help on using the changeset viewer.