Changeset 8174 in josm for trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
- Timestamp:
- 2015-04-07T09:00:22+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8168 r8174 8 8 import java.net.HttpURLConnection; 9 9 import java.net.MalformedURLException; 10 import java.net.URL; 10 11 import java.net.URLConnection; 11 12 import java.util.HashSet; … … 126 127 public void submit(ICachedLoaderListener listener) { 127 128 boolean first = false; 128 String url = getUrl().toString(); 129 if (url == null) { 129 URL url = getUrl(); 130 String deduplicationKey = null; 131 if (url != null) { 132 // url might be null, for example when Bing Attribution is not loaded yet 133 deduplicationKey = url.toString(); 134 } 135 if (deduplicationKey == null) { 130 136 log.log(Level.WARNING, "No url returned for: {0}, skipping", getCacheKey()); 131 137 return; 132 138 } 133 139 synchronized (inProgress) { 134 Set<ICachedLoaderListener> newListeners = inProgress.get( url);140 Set<ICachedLoaderListener> newListeners = inProgress.get(deduplicationKey); 135 141 if (newListeners == null) { 136 142 newListeners = new HashSet<>(); 137 inProgress.put( url, newListeners);143 inProgress.put(deduplicationKey, newListeners); 138 144 first = true; 139 145 } … … 162 168 163 169 /** 164 * 170 * 165 171 * @return checks if object from cache has sufficient data to be returned 166 172 */ … … 171 177 172 178 /** 173 * 179 * 174 180 * @return cache object as empty, regardless of what remote resource has returned (ex. based on headers) 175 181 */ … … 264 270 } 265 271 272 /** 273 * @return true if object was successfully downloaded, false, if there was a loading failure 274 */ 275 266 276 private boolean loadObject() { 267 277 try { … … 316 326 new Object[] {getCacheKey(), raw.length, getUrl()}); 317 327 return true; 318 } else { 328 } else { 319 329 cacheData = createCacheEntry(new byte[]{}); 320 330 cache.put(getCacheKey(), cacheData, attributes); … … 326 336 log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrl()); 327 337 cache.put(getCacheKey(), createCacheEntry(new byte[]{}), attributes); 328 handleNotFound(); 329 return true; 338 return handleNotFound(); 330 339 } catch (Exception e) { 331 340 log.log(Level.WARNING, "JCS - Exception during download " + getUrl(), e); … … 336 345 } 337 346 338 protected abstract void handleNotFound(); 347 /** 348 * @return if we should treat this object as properly loaded 349 */ 350 protected abstract boolean handleNotFound(); 339 351 340 352 protected abstract V createCacheEntry(byte[] content);
Note:
See TracChangeset
for help on using the changeset viewer.
