[GODRIVER-1246] Cursor.All() should end implicit session Created: 21/Aug/19 Updated: 28/Oct/23 Resolved: 04/Sep/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | CRUD |
| Affects Version/s: | None |
| Fix Version/s: | 1.1.1 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Pierre Durand | Assignee: | Alice Thum |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Description |
|
Currently Collection.Find() returns a Cursor and an error. The new Cursor.All() method is very helpful, because it allows to load the cursor to a slice. However I see 1 major problem: the cursor "API" is exposed to the user, and he must take care of closing it. If I understand correctly, if you don't close it, there is a leak. As a developer and reviewer, it's very easy to miss a cursor that isn't closed. It would be simpler/safer for a user that calls .All() to close the cursor automatically. I see 2 solutions:
|
| Comments |
| Comment by Githook User [ 05/Sep/19 ] |
|
Author: {'name': 'Alice Thum', 'email': 'alice.thum@10gen.com'}Message: Close cursor before returning from All. Change-Id: I907f4113c4f8c8428b176622edcb2bedc34fc9a6 |
| Comment by Alice Thum [ 04/Sep/19 ] |
|
commit link: https://github.com/mongodb/mongo-go-driver/commit/9c2e0a94c89a134b506777bd620c83ecf754974a |
| Comment by Githook User [ 04/Sep/19 ] |
|
Author: {'email': 'alice.thum@10gen.com', 'name': 'Alice Thum'}Message: Close cursor before returning from All. Change-Id: I907f4113c4f8c8428b176622edcb2bedc34fc9a6 |
| Comment by Alice Thum [ 28/Aug/19 ] |
|
gerrithub link: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/466622 |