Changeset 16431 in josm


Ignore:
Timestamp:
2020-05-16T22:28:34+02:00 (3 weeks ago)
Author:
simon04
Message:

TMSCachedTileLoaderJob.parseHeaders: use Utils.clamp

Fixes inconsistent TimeUnit.SECONDS.toMillis conversion (in if condition vs. statement).

File:
1 edited

Legend:

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

    r16398 r16431  
    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         if (ret.getExpirationTime() < now + Math.max(MINIMUM_EXPIRES.get(), options.getMinimumExpiryTime())) {
    264             ret.setExpirationTime(now + Math.max(MINIMUM_EXPIRES.get(), TimeUnit.SECONDS.toMillis(options.getMinimumExpiryTime())));
    265         }
    266         if (ret.getExpirationTime() > now + Math.max(MAXIMUM_EXPIRES.get(), options.getMinimumExpiryTime())) {
    267             ret.setExpirationTime(now + Math.max(MAXIMUM_EXPIRES.get(), TimeUnit.SECONDS.toMillis(options.getMinimumExpiryTime())));
    268         }
     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        ));
    269268        return ret;
    270269    }
Note: See TracChangeset for help on using the changeset viewer.