[SERVER-62231] Methods for iterating a DBClientCursor should assert that init() has been called Created: 22/Dec/21 Updated: 29/Oct/23 Resolved: 28/Jun/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Client |
| Affects Version/s: | None |
| Fix Version/s: | 6.1.0-rc0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Storch | Assignee: | Catalin Sumanaru |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | QE 2022-06-27, QE 2022-07-11 | ||||||||
| Participants: | |||||||||
| Linked BF Score: | 64 | ||||||||
| Description |
|
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:
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. |
| Comments |
| Comment by Githook User [ 28/Jun/22 ] |
|
Author: {'name': 'Catalin Sumanaru', 'email': 'catalin.sumanaru@mongodb.com'}Message: |
| Comment by Denis Grebennicov [ 07/Jun/22 ] |
|
Reserved for Catalin Sumanaru as neweng intern ticket work. |