[JAVA-4368] MongoCursor implementations should throw if iterated after close Created: 20/Oct/21 Updated: 03/Dec/21 Resolved: 03/Dec/21 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Query Operations |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Jeffrey Yemin | Assignee: | Jeffrey Yemin |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Currently, MongoCursor implementations may return results even after they have been closed, because they are relying on the underlying BatchCursor to throw an exception, even though it's still possible to return results from the current batch, e.g.
|
| Comments |
| Comment by Jeffrey Yemin [ 03/Dec/21 ] |
|
close is allowed to be called concurrently with iteration methods, which requires at minimum that we add a volatile field that is set in close and checked in iteration methods.. There is some cost to that, and it's not clear that it's worth the benefit that we get from throwing while iterating a closed cursor, given how rare that should be in practice. Closing as Won't Fix. |