Skip to content

Commit

Permalink
Fix zk cache expiration check (apache#8458)
Browse files Browse the repository at this point in the history
### Motivation
Currently, zk cache is refreshed every time because the units of comparison are different(ns and ms).
We should check the zk cache expiration time in the same unit.

(cherry picked from commit 37453b5)
  • Loading branch information
hrsakai authored and wolfstudy committed Nov 6, 2020
1 parent f23626e commit 156b4be
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private <T> void checkAndRefreshExpiredEntry(String path, final Deserializer<T>
if (result != null && result.isDone()) {
Pair<Entry<Object, Stat>, Long> entryPair = result.getNow(null);
if (entryPair != null && entryPair.getRight() != null) {
if ((System.nanoTime() - entryPair.getRight()) > TimeUnit.SECONDS.toMillis(cacheExpirySeconds)) {
if ((System.nanoTime() - entryPair.getRight()) > TimeUnit.SECONDS.toNanos(cacheExpirySeconds)) {
this.zkSession.get().getData(path, this, (rc, path1, ctx, content, stat) -> {
if (rc != Code.OK.intValue()) {
log.warn("Failed to refresh zookeeper-cache for {} due to {}", path, rc);
Expand Down

0 comments on commit 156b4be

Please sign in to comment.