Skip to content

Commit 9567271

Browse files
authored
GODRIVER-2631 - Always close internal.DefaultHTTPClient on Client.Disconnect (#1114)
1 parent 4a22ce6 commit 9567271

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mongo/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ func (c *Client) Disconnect(ctx context.Context) error {
281281
ctx = context.Background()
282282
}
283283

284+
if c.httpClient == internal.DefaultHTTPClient {
285+
defer internal.CloseIdleHTTPConnections(c.httpClient)
286+
}
287+
284288
c.endSessions(ctx)
285289
if c.mongocryptdFLE != nil {
286290
if err := c.mongocryptdFLE.disconnect(ctx); err != nil {
@@ -312,10 +316,6 @@ func (c *Client) Disconnect(ctx context.Context) error {
312316
return replaceErrors(disconnector.Disconnect(ctx))
313317
}
314318

315-
if c.httpClient == internal.DefaultHTTPClient {
316-
internal.CloseIdleHTTPConnections(c.httpClient)
317-
}
318-
319319
return nil
320320
}
321321

0 commit comments

Comments
 (0)