diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java index d8c0d7cd2..92e0b5553 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterMonitor.java @@ -149,7 +149,8 @@ public void run() { limitlessRouterCache.put( this.limitlessRouterCacheKey, - newLimitlessRouters, LimitlessRouterServiceImpl.MONITOR_DISPOSAL_TIME_MS.getLong(props)); + newLimitlessRouters, + TimeUnit.MILLISECONDS.toNanos(LimitlessRouterServiceImpl.MONITOR_DISPOSAL_TIME_MS.getLong(props))); RoundRobinHostSelector.setRoundRobinHostWeightPairsProperty(this.props, newLimitlessRouters); LOGGER.finest(Utils.logTopology(newLimitlessRouters, "[limitlessRouterMonitor] Topology:")); diff --git a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java index 778134d0f..c1ce73485 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java +++ b/wrapper/src/main/java/software/amazon/jdbc/plugin/limitless/LimitlessRouterServiceImpl.java @@ -289,7 +289,9 @@ protected void synchronouslyGetLimitlessRouters(final LimitlessConnectionContext context.setLimitlessRouters(newLimitlessRouters); limitlessRouterCache.put( this.pluginService.getHostListProvider().getClusterId(), - newLimitlessRouters, LimitlessRouterServiceImpl.MONITOR_DISPOSAL_TIME_MS.getLong(context.getProps())); + newLimitlessRouters, + TimeUnit.MILLISECONDS.toNanos( + LimitlessRouterServiceImpl.MONITOR_DISPOSAL_TIME_MS.getLong(context.getProps()))); } else { throw new SQLException(Messages.get("LimitlessRouterServiceImpl.fetchedEmptyRouterList")); } diff --git a/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java b/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java index 72b1eae67..43d7682a1 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java +++ b/wrapper/src/main/java/software/amazon/jdbc/util/SlidingExpirationCache.java @@ -100,11 +100,11 @@ public V put( final V value, final long itemExpirationNano) { cleanUp(); - final CacheItem cacheItem = cache.put(key, new CacheItem(value, itemExpirationNano)); + final CacheItem cacheItem = cache.put(key, new CacheItem(value, System.nanoTime() + itemExpirationNano)); if (cacheItem == null) { return null; } - return cacheItem.item; + return cacheItem.withExtendExpiration(itemExpirationNano).item; } public V get(final K key, final long itemExpirationNano) {