[GODRIVER-1292] ListCollectionNames does not appear to close the cursor it creates Created: 02/Sep/19  Updated: 28/Oct/23  Resolved: 02/Oct/19

Status: Closed
Project: Go Driver
Component/s: CRUD
Affects Version/s: 1.1.0
Fix Version/s: 1.1.2

Type: Bug Priority: Major - P3
Reporter: Ryan Wynn 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   

I might be missing something but it seems that res.Close(context.Background()) should be called within ListCollectionNames.   The cursor is not returned to the caller in this case so I think it should be closed internally. 

If this function does need a cursor Close() call then special attention would need to be made to ensure the cursor is closed if an error is encountered while iterating the results.  Currently, an error while iterating the results causes the function to immediately return the error.  



 Comments   
Comment by Githook User [ 02/Oct/19 ]

Author:

{'name': 'Alice Thum', 'username': 'athum', 'email': 'ayhthum@gmail.com'}

Message: Close cursor in Database.ListCollectionNames.

GODRIVER-1292

Change-Id: I02c8765de132c1e8a8267c473a24fb9784d3e8fd
Branch: release/1.1
https://github.com/mongodb/mongo-go-driver/commit/51b003868e5751abc69c8b7e874ac92b3271f358

Comment by Githook User [ 02/Oct/19 ]

Author:

{'name': 'Alice Thum', 'username': 'athum', 'email': 'ayhthum@gmail.com'}

Message: Close cursor in Database.ListCollectionNames.

GODRIVER-1292

Change-Id: I02c8765de132c1e8a8267c473a24fb9784d3e8fd
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/1def6e6cc7f1473f17383a81316641234913f0a5

Comment by Githook User [ 02/Oct/19 ]

Author:

{'username': 'athum', 'email': 'ayhthum@gmail.com', 'name': 'Alice Thum'}

Message: Close cursor in Database.ListCollectionNames.

GODRIVER-1292

Change-Id: I02c8765de132c1e8a8267c473a24fb9784d3e8fd
Branch: GODRIVER-1292
https://github.com/mongodb/mongo-go-driver/commit/e9f12a4efb775d2bd54d86caff5ce2fa656503f3

Comment by Alice Thum [ 01/Oct/19 ]

CR: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/470059

Comment by Ryan Wynn [ 02/Sep/19 ]

Actually, there is already a context, ctx, passed into the function, so maybe it should be closed as res.Close(ctx).

Generated at Thu Feb 08 08:36:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.