Skip to content

Commit

Permalink
Add deferred call to close DocumentResult's cursor
Browse files Browse the repository at this point in the history
GODRIVER-373

Change-Id: I7addfb359952a5abfccd40c59bf294d3e30be16a
  • Loading branch information
mattChiaravalloti committed Sep 13, 2018
1 parent fdda312 commit e0b7d07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions .errcheck-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(*github.com/mongodb/mongo-go-driver/core/topology.Server).Close
(*github.com/mongodb/mongo-go-driver/core/connection.pool).closeConnection
(github.com/mongodb/mongo-go-driver/core/wiremessage.ReadWriteCloser).Close
(github.com/mongodb/mongo-go-driver/mongo.Cursor).Close
(net.Conn).Close
encoding/pem.Encode
fmt.Fprintf
Expand Down
1 change: 1 addition & 0 deletions mongo/document_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (dr *DocumentResult) Decode(v interface{}) error {
}
return bson.Unmarshal(dr.rdr, v)
case dr.cur != nil:
defer dr.cur.Close(context.TODO())
if !dr.cur.Next(context.TODO()) {
if err := dr.cur.Err(); err != nil {
return err
Expand Down

0 comments on commit e0b7d07

Please sign in to comment.