Skip to content

Commit

Permalink
Merge pull request #85 from TykTechnologies/TT-10479
Browse files Browse the repository at this point in the history
[TT-10479] Deferring cursor closure only if no error is present
  • Loading branch information
mativm02 authored Nov 13, 2023
2 parents 1ebd6ca + e2bb01f commit 517e1d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion persistent/internal/driver/mongo/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (d *mongoDriver) Query(ctx context.Context, row model.DBObject, result inte
cursor, err = collection.Find(ctx, search, findOpts)
if err == nil {
err = cursor.All(ctx, result)
defer cursor.Close(ctx)
}
defer cursor.Close(ctx)
} else {
err = collection.FindOne(ctx, search, findOneOpts).Decode(result)
}
Expand Down

0 comments on commit 517e1d2

Please sign in to comment.