Skip to content

Commit 1cb4b30

Browse files
committed
Avoid redundant killing of the cursor by setting a flag indicating that it's already been killed.
JAVA-1854
1 parent ca1f335 commit 1cb4b30

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class QueryBatchCursor<T> implements BatchCursor<T> {
3939
private final ConnectionSource connectionSource;
4040
private int batchSize;
4141
private ServerCursor serverCursor;
42+
private boolean killed;
4243
private List<T> nextBatch;
4344
private int count;
4445
private boolean closed;
@@ -228,8 +229,9 @@ private void killCursor() {
228229
}
229230

230231
private void killCursor(final Connection connection) {
231-
if (serverCursor != null) {
232+
if (serverCursor != null && !killed) {
232233
connection.killCursor(asList(serverCursor.getId()));
234+
killed = true;
233235
}
234236
}
235237
}

0 commit comments

Comments
 (0)