Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 04ffcf5

Browse files
committed
fix: checks pool maintainer is not closed on close
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.
1 parent 1363543 commit 04ffcf5

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,10 +1617,12 @@ public void run() {
16171617

16181618
void close() {
16191619
synchronized (lock) {
1620-
closed = true;
1621-
scheduledFuture.cancel(false);
1622-
if (!running) {
1623-
decrementPendingClosures(1);
1620+
if (!closed) {
1621+
closed = true;
1622+
scheduledFuture.cancel(false);
1623+
if (!running) {
1624+
decrementPendingClosures(1);
1625+
}
16241626
}
16251627
}
16261628
}
@@ -2188,11 +2190,11 @@ ListenableFuture<Void> closeAsync(ClosedException closedException) {
21882190
closeSessionAsync(session);
21892191
}
21902192
}
2191-
}
21922193

2193-
// Nothing to be closed, mark as complete
2194-
if (pendingClosure == 0) {
2195-
closureFuture.set(null);
2194+
// Nothing to be closed, mark as complete
2195+
if (pendingClosure == 0) {
2196+
closureFuture.set(null);
2197+
}
21962198
}
21972199

21982200
retFuture.addListener(

0 commit comments

Comments
 (0)