Skip to content

Commit 212acef

Browse files
committed
HostConnectionPool pendingBorrows can be nil at closing (#465)
SessionManager.replacePool adds pool to the pools map and only afterwards calls initAsync. For short period of time pool stays in `SessionManager.pools` uninitialized. If you close session in that exact time `HostConnectionPool.closeAsync` is going to endup in panic, because `pendingBorrows` is null : ``` java.lang.NullPointerException: null at com.datastax.driver.core.HostConnectionPool.closeAsync(HostConnectionPool.java:978) ```
1 parent caef4e6 commit 212acef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,12 @@ final CloseFuture closeAsync() {
975975

976976
phase.set(Phase.CLOSING);
977977

978-
for (Queue<PendingBorrow> queue : pendingBorrows) {
979-
for (PendingBorrow pendingBorrow : queue) {
980-
pendingBorrow.setException(new ConnectionException(host.getEndPoint(), "Pool is shutdown"));
978+
if (pendingBorrows != null) {
979+
for (Queue<PendingBorrow> queue : pendingBorrows) {
980+
for (PendingBorrow pendingBorrow : queue) {
981+
pendingBorrow.setException(
982+
new ConnectionException(host.getEndPoint(), "Pool is shutdown"));
983+
}
981984
}
982985
}
983986

0 commit comments

Comments
 (0)