Skip to content

Commit

Permalink
fix: checks pool maintainer is not closed on close
Browse files Browse the repository at this point in the history
Verifies that the pool maintainer is not closed before closing it. Also
moves the check of pendingClosures into the synchronized block to make
sure no stale reads are made.
  • Loading branch information
thiagotnunes committed Jan 14, 2021
1 parent 1363543 commit 04ffcf5
Showing 1 changed file with 10 additions and 8 deletions.
Expand Up @@ -1617,10 +1617,12 @@ public void run() {

void close() {
synchronized (lock) {
closed = true;
scheduledFuture.cancel(false);
if (!running) {
decrementPendingClosures(1);
if (!closed) {
closed = true;
scheduledFuture.cancel(false);
if (!running) {
decrementPendingClosures(1);
}
}
}
}
Expand Down Expand Up @@ -2188,11 +2190,11 @@ ListenableFuture<Void> closeAsync(ClosedException closedException) {
closeSessionAsync(session);
}
}
}

// Nothing to be closed, mark as complete
if (pendingClosure == 0) {
closureFuture.set(null);
// Nothing to be closed, mark as complete
if (pendingClosure == 0) {
closureFuture.set(null);
}
}

retFuture.addListener(
Expand Down

0 comments on commit 04ffcf5

Please sign in to comment.