-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: API
-
None
-
Environment:Linux Ubuntu 11.04, mongod 2.0.5
When iterating over a DBCursor using standard hasNext()/next() logic, hasNext() can raise a NullPointerException when the underlying server-side cursor has been closed. This happens in my code because I wrap the DBCursor in another Iterator that provides "batching": Iterates over the DBCursor generating a list of objects instead of a single object.
I has been able to trace the issue to the following code fragments in DBApiLayer:
public boolean hasNext(){ boolean hasNext = _cur.hasNext(); while ( !hasNext ) { .... } return hasNext; } ... void close(){ if (_curResult != null) { killCursor(); _curResult = null; _cur = null; } }
Please the documentation tells the hasNext() method can throw a MongoException and there are some issues that deal with this API issue.
- related to
-
JAVA-1091 Always set awaitData along with tailable
- Closed