Changeset 8344 in josm for trunk/src/org/openstreetmap/josm/data/cache
- Timestamp:
- 2015-05-10T13:27:54+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/cache
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/BufferedImageCacheEntry.java
r8168 r8344 43 43 return img; 44 44 byte[] content = getContent(); 45 if (content != null ) {45 if (content != null && content.length > 0) { 46 46 img = ImageIO.read(new ByteArrayInputStream(content)); 47 47 -
trunk/src/org/openstreetmap/josm/data/cache/ICachedLoaderListener.java
r8176 r8344 20 20 * 21 21 * @param data 22 * @param attributes 22 23 * @param result 23 24 */ 24 public void loadingFinished(CacheEntry data, LoadResult result);25 public void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result); 25 26 26 27 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8326 r8344 10 10 import java.net.URLConnection; 11 11 import java.util.HashSet; 12 import java.util.List; 12 13 import java.util.Map; 13 14 import java.util.Random; … … 224 225 * @return cache object as empty, regardless of what remote resource has returned (ex. based on headers) 225 226 */ 226 protected boolean cacheAsEmpty( ) {227 protected boolean cacheAsEmpty(Map<String, List<String>> headers, int statusCode, byte[] content) { 227 228 return false; 228 229 } … … 280 281 try { 281 282 for (ICachedLoaderListener l: listeners) { 282 l.loadingFinished(cacheData, result);283 l.loadingFinished(cacheData, attributes, result); 283 284 } 284 285 } catch (Exception e) { … … 286 287 Main.warn(e); 287 288 for (ICachedLoaderListener l: listeners) { 288 l.loadingFinished(cacheData, LoadResult.FAILURE);289 l.loadingFinished(cacheData, attributes, LoadResult.FAILURE); 289 290 } 290 291 … … 329 330 return true; 330 331 } 331 URLConnection urlConn = getURLConnection();332 HttpURLConnection urlConn = getURLConnection(); 332 333 333 334 if (isObjectLoadable() && … … 338 339 urlConn.addRequestProperty("If-None-Match", attributes.getEtag()); 339 340 } 340 if (urlConn instanceof HttpURLConnection && ((HttpURLConnection)urlConn).getResponseCode() == 304) {341 if (urlConn.getResponseCode() == 304) { 341 342 // If isModifiedSince or If-None-Match has been set 342 343 // and the server answers with a HTTP 304 = "Not Modified" … … 359 360 360 361 for (int i = 0; i < 5; ++i) { 361 if (urlConn instanceof HttpURLConnection && ((HttpURLConnection)urlConn).getResponseCode() == 503) {362 if (urlConn.getResponseCode() == 503) { 362 363 Thread.sleep(5000+(new Random()).nextInt(5000)); 363 364 continue; … … 365 366 byte[] raw = read(urlConn); 366 367 367 if (!cacheAsEmpty() && raw != null && raw.length > 0) { 368 if (!cacheAsEmpty(urlConn.getHeaderFields(), urlConn.getResponseCode(), raw) && 369 raw != null && raw.length > 0) { 368 370 cacheData = createCacheEntry(raw); 369 371 cache.put(getCacheKey(), cacheData, attributes); … … 400 402 private CacheEntryAttributes parseHeaders(URLConnection urlConn) { 401 403 CacheEntryAttributes ret = new CacheEntryAttributes(); 402 ret.setNoTileAtZoom("no-tile".equals(urlConn.getHeaderField("X-VE-Tile-Info")));403 404 404 405 Long lng = urlConn.getExpiration();
Note:
See TracChangeset
for help on using the changeset viewer.