Changeset 8424 in josm


Ignore:
Timestamp:
2015-05-24T22:48:58+02:00 (9 years ago)
Author:
wiktorn
Message:

Set URLConnection.setUseCaches(false) when forcing reload of tiles. Closes #11379

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/ICachedLoaderJob.java

    r8168 r8424  
    66
    77/**
    8  * 
     8 *
    99 * @author Wiktor Niesiobędzki
    1010 *
     
    1414    /**
    1515     * returns cache entry key
    16      * 
     16     *
    1717     * @param tile
    1818     * @return cache key for tile
     
    2323     * method to get download URL for Job
    2424     * @return URL that should be fetched
    25      * 
     25     *
    2626     */
    2727    public URL getUrl();
     
    3333    /**
    3434     * fetches object from cache, or returns null when object is not found
    35      * 
     35     *
    3636     * @return filled tile with data or null when no cache entry found
    3737     */
     
    4141     * Submit job for background fetch, and listener will be
    4242     * fed with value object
    43      * 
     43     *
    4444     * @param listener
     45     * @param force true if the load should skip all the caches (local & remote)
    4546     */
    46     public void submit(ICachedLoaderListener listener);
     47    public void submit(ICachedLoaderListener listener, boolean force);
    4748}
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8413 r8424  
    109109    private ThreadPoolExecutor downloadJobExecutor;
    110110    private Runnable finishTask;
     111    private boolean force = false;
    111112
    112113    /**
     
    159160
    160161    @Override
    161     public void submit(ICachedLoaderListener listener) {
     162    public void submit(ICachedLoaderListener listener, boolean force) {
     163        this.force = force;
    162164        boolean first = false;
    163165        URL url = getUrl();
     
    181183        }
    182184
    183         if (first) {
     185        if (first || force) {
    184186            ensureCacheElement();
    185             if (cacheElement != null && isCacheElementValid() && (isObjectLoadable())) {
     187            if (!force && cacheElement != null && isCacheElementValid() && (isObjectLoadable())) {
    186188                // we got something in cache, and it's valid, so lets return it
    187189                log.log(Level.FINE, "JCS - Returning object from cache: {0}", getCacheKey());
     
    234236    }
    235237
     238    @Override
    236239    public void run() {
    237240        final Thread currentThread = Thread.currentThread();
     
    429432            urlConn.setRequestProperty(e.getKey(), e.getValue());
    430433        }
     434        if (force) {
     435            urlConn.setUseCaches(false);
     436        }
    431437        return urlConn;
    432438    }
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r8418 r8424  
    154154    }
    155155
    156     public void submit() {
     156    @Override
     157    public void submit(boolean force) {
    157158        tile.initLoading();
    158         super.submit(this);
     159        super.submit(this, force);
    159160    }
    160161
     
    282283        return new BufferedImageCacheEntry(content);
    283284    }
     285
     286    @Override
     287    public void submit() {
     288        submit(false);
     289    }
    284290}
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r8418 r8424  
    602602                if (clickedTile != null) {
    603603                    clickedTile.setLoaded(false);
    604                     tileLoader.createTileLoaderJob(clickedTile).submit();
     604                    tileLoader.createTileLoaderJob(clickedTile).submit(true);
    605605                }
    606606            }
     
    847847        if (tile.isLoading())
    848848            return false;
    849         tileLoader.createTileLoaderJob(tile).submit();
     849        tileLoader.createTileLoaderJob(tile).submit(force);
    850850        return true;
    851851    }
     
    12591259            List<Tile> allTiles = allTilesCreate();
    12601260            Collections.sort(allTiles, getTileDistanceComparator());
    1261             for (Tile t : allTiles) { //, getTileDistanceComparator())) {
    1262                 loadTile(t, false);
     1261            for (Tile t : allTiles) {
     1262                loadTile(t, force);
    12631263            }
    12641264        }
Note: See TracChangeset for help on using the changeset viewer.