/** * Computes the delay until the next refresh time based on the current metadata's expiration time and the refresh * interval floor. * * @param expectedExpiration the time when the metadata is expected to expire and need refreshing * * @return delay, in milliseconds, until the next refresh time */ protected long computeNextRefreshDelay(DateTime expectedExpiration) { long now = new DateTime(ISOChronology.getInstanceUTC()).getMillis(); long expireInstant = 0; if (expectedExpiration != null) { expireInstant = expectedExpiration.toDateTime(ISOChronology.getInstanceUTC()).getMillis(); } long refreshDelay = (long) ((expireInstant - now) * getRefreshDelayFactor()); // if the expiration time was null or the calculated refresh delay was less than the floor // use the floor if (refreshDelay < getMinRefreshDelay()) { refreshDelay = getMinRefreshDelay(); } return refreshDelay; }