Skip to content

Commit cbfae84

Browse files
committed
Add timeout to ServerHelper.waitForLastRelease so that a broken test will fail quickly
1 parent 70bf114 commit cbfae84

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

driver-core/src/test/functional/com/mongodb/connection/ServerHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,14 @@ public static void waitForLastRelease(final ServerAddress address, final Cluster
3838
DefaultServer server = (DefaultServer) cluster.selectServer(new ServerAddressSelector(address));
3939
DefaultConnectionPool connectionProvider = (DefaultConnectionPool) server.getConnectionPool();
4040
ConcurrentPool<UsageTrackingInternalConnection> pool = connectionProvider.getPool();
41+
long startTime = System.currentTimeMillis();
4142
while (pool.getInUseCount() > 0) {
4243
try {
4344
sleep(10);
45+
if (System.currentTimeMillis() > startTime + ClusterFixture.TIMEOUT * 1000) {
46+
throw new MongoTimeoutException("Timed out waiting for pool in use count to drop to 0. Now at: "
47+
+ pool.getInUseCount());
48+
}
4449
} catch (InterruptedException e) {
4550
throw new MongoInterruptedException("Interrupted", e);
4651
}

0 commit comments

Comments
 (0)