Skip to content

Commit

Permalink
GODRIVER-2631 - Always close internal.DefaultHTTPClient on Client.Dis…
Browse files Browse the repository at this point in the history
…connect (#1114)
  • Loading branch information
edaniels authored Nov 1, 2022
1 parent 4a22ce6 commit 9567271
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mongo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ func (c *Client) Disconnect(ctx context.Context) error {
ctx = context.Background()
}

if c.httpClient == internal.DefaultHTTPClient {
defer internal.CloseIdleHTTPConnections(c.httpClient)
}

c.endSessions(ctx)
if c.mongocryptdFLE != nil {
if err := c.mongocryptdFLE.disconnect(ctx); err != nil {
Expand Down Expand Up @@ -312,10 +316,6 @@ func (c *Client) Disconnect(ctx context.Context) error {
return replaceErrors(disconnector.Disconnect(ctx))
}

if c.httpClient == internal.DefaultHTTPClient {
internal.CloseIdleHTTPConnections(c.httpClient)
}

return nil
}

Expand Down

0 comments on commit 9567271

Please sign in to comment.