- Timestamp:
- 2015-05-17T22:48:00+02:00 (10 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
r8318 r8389 20 20 private static final String LAST_MODIFICATION = "lastModification"; 21 21 private static final String EXPIRATION_TIME = "expirationTime"; 22 private static final String HTTP_RESPONSE_CODE = "httpResponceCode"; 22 23 23 24 /** … … 30 31 attrs.put(LAST_MODIFICATION, "0"); 31 32 attrs.put(EXPIRATION_TIME, "0"); 33 attrs.put(HTTP_RESPONSE_CODE, "200"); 32 34 } 33 35 … … 46 48 47 49 private long getLongAttr(String key) { 50 String val = attrs.get(key); 51 if (val == null) { 52 attrs.put(key, "0"); 53 return 0; 54 } 48 55 try { 49 return Long.parseLong( attrs.get(key));56 return Long.parseLong(val); 50 57 } catch (NumberFormatException e) { 51 58 attrs.put(key, "0"); … … 67 74 } 68 75 76 public void setResponseCode(int responseCode) { 77 attrs.put(HTTP_RESPONSE_CODE, Integer.toString(responseCode)); 78 } 79 80 public int getResponseCode() { 81 return (int) getLongAttr(HTTP_RESPONSE_CODE); 82 } 83 69 84 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8345 r8389 364 364 continue; 365 365 } 366 367 attributes.setResponseCode(urlConn.getResponseCode()); 366 368 byte[] raw = read(urlConn); 367 369 368 370 if (!cacheAsEmpty(urlConn.getHeaderFields(), urlConn.getResponseCode(), raw) && 369 371 raw != null && raw.length > 0) { 372 // we need to check cacheEmpty, so for cases, when data is returned, but we want to store 373 // as empty (eg. empty tile images) to save some space 370 374 cacheData = createCacheEntry(raw); 371 375 cache.put(getCacheKey(), cacheData, attributes); -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r8344 r8389 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.imagery; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.io.ByteArrayInputStream; … … 273 275 } 274 276 } 277 int httpStatusCode = attributes.getResponseCode(); 278 if (!isNoTileAtZoom() && httpStatusCode >= 400) { 279 tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode)); 280 } 275 281 // no break intentional here 276 282 case REJECTED: … … 313 319 tile.finishLoading(); 314 320 } 321 if (attributes.getResponseCode() >= 400) { 322 tile.setError(tr("HTTP error {0} when loading tiles", attributes.getResponseCode())); 323 } 315 324 return tile; 316 325 } catch (IOException e) {
Note:
See TracChangeset
for help on using the changeset viewer.