[JAVA-4733] Log warning on possible incorrect use of sessions Created: 22/Sep/22 Updated: 26/Sep/22 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | Logging |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Jeffrey Yemin | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
It's too easy to neglect passing in the ClientSession to a CRUD operation even when the session is started in the current lexical scope. Consider adding a warning to the logs if this possibly incorrect usage is detected. Pseudocode would be something like:
Also consider adding an option that would cause the driver to throw a MongoClientException instead of logging a warning. To opt-out of the behavior on a per-call basis, consider adding some sort of "null" ClientSession to indicate that you really meant to leave it out. Also consider whether this behavior should be restricted to sessions with active transactions, or just any open session. Also consider whether there should be a global opt-out for the entire new behavior. For example, this wouldn't play well with the unified tests. Finally, consider whether this should be promoted to a DRIVERS ticket. |