Skip to content

Commit 5391df1

Browse files
committed
JAVA-772: If cursor is not found by the server, report in the exception the cursor that was requested
1 parent d647ccd commit 5391df1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/com/mongodb/DBApiLayer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,16 @@ class Result implements Iterator<DBObject> {
362362
}
363363

364364
private void init( Response res ){
365+
if ( ( res._flags & Bytes.RESULTFLAG_CURSORNOTFOUND ) > 0 ){
366+
throw new MongoException.CursorNotFound(_curResult.cursor(), res.serverUsed());
367+
}
368+
365369
_totalBytes += res._len;
366370
_curResult = res;
367371
_cur = res.iterator();
368372
_sizes.add( res.size() );
369373
_numFetched += res.size();
370374

371-
if ( ( res._flags & Bytes.RESULTFLAG_CURSORNOTFOUND ) > 0 ){
372-
throw new MongoException.CursorNotFound(res._cursor, res.serverUsed());
373-
}
374-
375375
if (res._cursor != 0 && _limit > 0 && _limit - _numFetched <= 0) {
376376
// fetched all docs within limit, close cursor server-side
377377
killCursor();

0 commit comments

Comments
 (0)