Skip to content

Commit e0b7d07

Browse files
Add deferred call to close DocumentResult's cursor
GODRIVER-373 Change-Id: I7addfb359952a5abfccd40c59bf294d3e30be16a
1 parent fdda312 commit e0b7d07

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

.errcheck-excludes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(*github.com/mongodb/mongo-go-driver/core/topology.Server).Close
55
(*github.com/mongodb/mongo-go-driver/core/connection.pool).closeConnection
66
(github.com/mongodb/mongo-go-driver/core/wiremessage.ReadWriteCloser).Close
7+
(github.com/mongodb/mongo-go-driver/mongo.Cursor).Close
78
(net.Conn).Close
89
encoding/pem.Encode
910
fmt.Fprintf

mongo/document_result.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func (dr *DocumentResult) Decode(v interface{}) error {
4040
}
4141
return bson.Unmarshal(dr.rdr, v)
4242
case dr.cur != nil:
43+
defer dr.cur.Close(context.TODO())
4344
if !dr.cur.Next(context.TODO()) {
4445
if err := dr.cur.Err(); err != nil {
4546
return err

0 commit comments

Comments
 (0)