Ignore:
Timestamp:
2020-06-21T10:02:29+02:00 (4 years ago)
Author:
simon04
Message:

fix #19422 - IAE in TMSCachedTileLoaderJob.parseHeaders

File:
1 edited

Legend:

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

    r16431 r16692  
    261261        // keep the expiration time between MINIMUM_EXPIRES and MAXIMUM_EXPIRES, so we will cache the tiles
    262262        // at least for some short period of time, but not too long
    263         ret.setExpirationTime((long) Utils.clamp(
    264                 ret.getExpirationTime(),
    265                 now + Math.max(MINIMUM_EXPIRES.get(), TimeUnit.SECONDS.toMillis(options.getMinimumExpiryTime())),
    266                 now + Math.max(MAXIMUM_EXPIRES.get(), TimeUnit.SECONDS.toMillis(options.getMinimumExpiryTime()))
    267         ));
     263        long minimumExpiryTime = TimeUnit.SECONDS.toMillis(options.getMinimumExpiryTime());
     264        long nowPlusMin = now + Math.max(MINIMUM_EXPIRES.get(), minimumExpiryTime);
     265        if (ret.getExpirationTime() < nowPlusMin) {
     266            ret.setExpirationTime(nowPlusMin);
     267        }
     268        long nowPlusMax = now + Math.max(MAXIMUM_EXPIRES.get(), minimumExpiryTime);
     269        if (ret.getExpirationTime() > nowPlusMax) {
     270            ret.setExpirationTime(nowPlusMax);
     271        }
    268272        return ret;
    269273    }
Note: See TracChangeset for help on using the changeset viewer.