Ignore:
Timestamp:
2015-05-28T22:00:41+02:00 (9 years ago)
Author:
wiktorn
Message:

Clean up handling of various error situations. Closes #11494

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r8425 r8433  
    137137
    138138    @Override
    139     protected boolean cacheAsEmpty(Map<String, List<String>> headers, int statusCode, byte[] content) {
    140         // cacheAsEmpty is called for every successful download, so we can put
    141         // metadata handling here
     139    protected boolean isResponseLoadable(Map<String, List<String>> headers, int statusCode, byte[] content) {
    142140        attributes.setMetadata(tile.getTileSource().getMetadata(headers));
    143141        if (tile.getTileSource().isNoTileAtZoom(headers, statusCode, content)) {
    144142            attributes.setNoTileAtZoom(true);
    145             return true;
    146         }
    147         return false;
     143            return false; // do no try to load data from no-tile at zoom, cache empty object instead
     144        }
     145        return super.isResponseLoadable(headers, statusCode, content);
     146    }
     147
     148    @Override
     149    protected boolean cacheAsEmpty() {
     150        return isNoTileAtZoom() || super.cacheAsEmpty();
    148151    }
    149152
     
    171174            listeners = inProgress.remove(getCacheKey());
    172175        }
     176        boolean status = result.equals(LoadResult.SUCCESS);
    173177
    174178        try {
     
    194198                    if (!isNoTileAtZoom() && httpStatusCode >= 400) {
    195199                        tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
     200                        status = false;
    196201                    }
    197202                    break;
     
    207212            if (listeners != null) { // listeners might be null, if some other thread notified already about success
    208213                for(TileLoaderListener l: listeners) {
    209                     l.tileLoadingFinished(tile, result.equals(LoadResult.SUCCESS));
     214                    l.tileLoadingFinished(tile, status);
    210215                }
    211216            }
     
    259264    }
    260265
    261     @Override
    262     protected boolean handleNotFound() {
    263         if (tile.getSource().isNoTileAtZoom(null, 404, null)) {
    264             tile.setError("No tile at this zoom level");
    265             tile.putValue("tile-info", "no-tile");
    266             return true;
    267         }
    268         return false;
    269     }
    270 
    271266    /**
    272267     * For TMS use BaseURL as settings discovery, so for different paths, we will have different settings (useful for developer servers)
Note: See TracChangeset for help on using the changeset viewer.