Skip to content

Commit 51b0038

Browse files
committed
Close cursor in Database.ListCollectionNames.
GODRIVER-1292 Change-Id: I02c8765de132c1e8a8267c473a24fb9784d3e8fd
1 parent af8e6c2 commit 51b0038

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mongo/database.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ func (db *Database) ListCollectionNames(ctx context.Context, filter interface{},
317317
return nil, err
318318
}
319319

320+
defer res.Close(ctx)
321+
320322
names := make([]string, 0)
321323
for res.Next(ctx) {
322324
next := &bsonx.Doc{}
@@ -338,6 +340,7 @@ func (db *Database) ListCollectionNames(ctx context.Context, filter interface{},
338340
names = append(names, elemName)
339341
}
340342

343+
res.Close(ctx)
341344
return names, nil
342345
}
343346

0 commit comments

Comments
 (0)