-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Client
-
Fully Compatible
-
QE 2022-06-27, QE 2022-07-11
-
64
In order to fully initialize a DBClientCursor object, one must first call its constructor and then subsequently call DBClientCursor::init(). If the programmer makes a mistake and fails to call init(), the cursor can silently return no results rather than raising an error. Consider code like this:
DBClientCursor cursor{...}; while (cursor->more()) { BSONObj obj = cursor->nextSafe(); // Do something with 'obj'. }
This code is incorrect, since it fails to call init(). However, the call to cursor->more() simply returns false rather than throwing or tripping an assertion, so the bug could easily go undetected. We should improve the code to uassert() or possibly invariant() in this scenario.
- causes
-
SERVER-92797 Fix behavior when running next() over a closed exhaust cursor
- Closed
- is related to
-
SERVER-61385 Migrate most callers of legacy 'DBClientBase::query()' API to modern 'find()' API
- Closed