Skip to content

Commit afd41e0

Browse files
committed
Check for null connection in AsyncConnectionSource.getConnection callback.
1 parent 8492ba2 commit afd41e0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

driver-core/src/main/com/mongodb/operation/AsyncQueryBatchCursor.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,15 @@ private void killCursor() {
142142
localConnectionSource.getConnection(new SingleResultCallback<AsyncConnection>() {
143143
@Override
144144
public void onResult(final AsyncConnection connection, final Throwable connectionException) {
145-
connection.killCursorAsync(singletonList(localCursor.getId()), new SingleResultCallback<Void>() {
146-
@Override
147-
public void onResult(final Void result, final Throwable t) {
148-
connection.release();
149-
localConnectionSource.release();
150-
}
151-
});
145+
if (connection != null) {
146+
connection.killCursorAsync(singletonList(localCursor.getId()), new SingleResultCallback<Void>() {
147+
@Override
148+
public void onResult(final Void result, final Throwable t) {
149+
connection.release();
150+
localConnectionSource.release();
151+
}
152+
});
153+
}
152154
}
153155
});
154156
} else if (connectionSource != null) {

0 commit comments

Comments
 (0)