Skip to content

Commit 87113ea

Browse files
committed
JAVA-2034: Stop interrupting the wait queue handler in BaseCluster, as it's possible that the interrupt flag will be checked somewhere else besides the wait queue handler itself.
Additionally, ensure that exceptions thrown in DefaultConnectionPool.getAsync are propagated to the callback.
1 parent fb05eb3 commit 87113ea

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

driver-core/src/main/com/mongodb/connection/BaseCluster.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,6 @@ private synchronized void notifyWaitQueueHandler(final ServerSelectionRequest re
429429
waitQueueHandler = new Thread(new WaitQueueHandler(), "cluster-" + clusterId.getValue());
430430
waitQueueHandler.setDaemon(true);
431431
waitQueueHandler.start();
432-
} else {
433-
waitQueueHandler.interrupt();
434432
}
435433
}
436434
}
@@ -466,9 +464,7 @@ public void run() {
466464
try {
467465
currentPhase.await(waitTimeNanos, NANOSECONDS);
468466
} catch (InterruptedException e) {
469-
// Either we were interrupted because the wait queue has been added to, or because the cluster has been
470-
// closed. If the latter, the while loop will exit. If the former, we check all waiters, since we don't know which
471-
// one was added
467+
// The cluster has been closed and the while loop will exit.
472468
}
473469
}
474470
// Notify all remaining waiters that a shutdown is in progress

driver-core/src/main/com/mongodb/connection/DefaultConnectionPool.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ public void getAsync(final SingleResultCallback<InternalConnection> callback) {
124124
connection = getPooledConnection(0, MILLISECONDS);
125125
} catch (MongoTimeoutException e) {
126126
// fall through
127+
} catch (Throwable t) {
128+
callback.onResult(null, t);
129+
return;
127130
}
128131

129132
if (connection != null) {

0 commit comments

Comments
 (0)