Skip to content

Commit

Permalink
Update the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
thachlp committed Feb 19, 2025
1 parent 370a172 commit be55f44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,13 @@ private static class ClusterTopologyRefreshTask extends AtomicBoolean implements

public void run() {

refreshLock.lock();
try {
if (compareAndSet(false, true)) {
doRun();
return;
}

if (logger.isDebugEnabled()) {
logger.debug("ClusterTopologyRefreshTask already in progress");
}
} finally {
refreshLock.unlock();
if (compareAndSet(false, true)) {
doRun();
return;
}

if (logger.isDebugEnabled()) {
logger.debug("ClusterTopologyRefreshTask already in progress");
}
}

Expand All @@ -366,6 +361,8 @@ void doRun() {

refreshLock.lock();
try {
reloadTopologyAsync.get();

set(false);
refreshComplete.signalAll();
} finally {
Expand Down
12 changes: 1 addition & 11 deletions src/main/java/io/lettuce/core/cluster/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1155,22 +1155,12 @@ public CompletableFuture<Void> shutdownAsync(long quietPeriod, long timeout, Tim

suspendTopologyRefresh();
ReentrantLock refreshLock = topologyRefreshScheduler.getRefreshLock();
Condition refreshComplete = topologyRefreshScheduler.getRefreshComplete();

refreshLock.lock();
try {
while (topologyRefreshScheduler.isTopologyRefreshInProgress()) {
try {
refreshComplete.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
return super.shutdownAsync(quietPeriod, timeout, timeUnit);
} finally {
refreshLock.unlock();
}

return super.shutdownAsync(quietPeriod, timeout, timeUnit);
}

// -------------------------------------------------------------------------
Expand Down

0 comments on commit be55f44

Please sign in to comment.