Skip to content

Commit 4b7f909

Browse files
committed
[JAVA-304]: cursors with negative id were not being closed
1 parent 8f9b11e commit 4b7f909

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/com/mongodb/DBApiLayer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ private void init( Response res ){
371371
throw new MongoException.CursorNotFound();
372372
}
373373

374-
if (res._cursor > 0 && _limit > 0 && _limit - _numFetched <= 0) {
374+
if (res._cursor != 0 && _limit > 0 && _limit - _numFetched <= 0) {
375375
// fetched all docs within limit, close cursor server-side
376376
killCursor();
377377
}
@@ -439,7 +439,7 @@ protected void finalize() throws Throwable {
439439
long curId = _curResult.cursor();
440440
_curResult = null;
441441
_cur = null;
442-
if (curId > 0) {
442+
if (curId != 0) {
443443
_deadCursorIds.add(new DeadCursor(curId, _host));
444444
}
445445
}
@@ -477,7 +477,7 @@ void killCursor() {
477477
if (_curResult == null)
478478
return;
479479
long curId = _curResult.cursor();
480-
if (curId <= 0)
480+
if (curId == 0)
481481
return;
482482

483483
List<Long> l = new ArrayList<Long>();

src/main/com/mongodb/Response.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public Iterator<DBObject> iterator(){
8484
}
8585

8686
public boolean hasGetMore( int queryOptions ){
87-
if ( _cursor <= 0 )
87+
if ( _cursor == 0 )
8888
return false;
8989

9090
if ( _num > 0 )

0 commit comments

Comments
 (0)