Skip to content

Commit 1f8f13e

Browse files
committed
Catch Error subclass of Throwable to ensure that a socket in an undefined state is not returned to the pool.
JAVA-1780
1 parent 4996876 commit 1f8f13e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/com/mongodb/DBTCPConnector.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ <T> T doOperation(final DB db, final DBPort port, final DBPort.Operation<T> oper
218218
_myPort.error(port, re);
219219
throw re;
220220
}
221+
catch ( Error e ){
222+
_myPort.error(port, e);
223+
throw e;
224+
}
221225
}
222226

223227
/**
@@ -301,6 +305,10 @@ private Response innerCall(final DB db, final DBCollection coll, final OutMessag
301305
catch ( RuntimeException re ){
302306
_myPort.error(port, re);
303307
throw re;
308+
}
309+
catch ( Error e ){
310+
_myPort.error(port, e);
311+
throw e;
304312
} finally {
305313
_myPort.done(port);
306314
}
@@ -476,10 +484,10 @@ void done( DBPort port ) {
476484
/**
477485
* call this method when there is an IOException or other low level error on port.
478486
* @param port
479-
* @param e
487+
* @param t
480488
*/
481-
void error( DBPort port , Exception e ){
482-
if (!(e instanceof InterruptedIOException)) {
489+
void error( DBPort port , Throwable t ){
490+
if (!(t instanceof InterruptedIOException)) {
483491
try {
484492
// no need to wait if the server is no longer available
485493
cluster.getServer(new ServerAddressSelector(port.getAddress()), 1, NANOSECONDS).invalidate();

0 commit comments

Comments
 (0)