Fix closing the body for HTTP requests#11842
Merged
frouioui merged 1 commit intovitessio:mainfrom Nov 29, 2022
Merged
Conversation
One of the easy things to miss that can cause resource leaks is not closing a response body for an HTTP request. There's a linter available to make it easier to catch this, so this enables that linter and fixes all the cases reported. This is almost all test cases, except for one production code path case in the throttler. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
dbussink
commented
Nov 29, 2022
| mySQLThrottleMetric.Err = err | ||
| return mySQLThrottleMetric | ||
| } | ||
| defer resp.Body.Close() |
Member
Author
There was a problem hiding this comment.
This is the only non-test case that the linter has found here.
frouioui
approved these changes
Nov 29, 2022
harshit-gangal
approved these changes
Nov 29, 2022
dbussink
added a commit
to planetscale/vitess
that referenced
this pull request
Nov 30, 2022
One of the easy things to miss that can cause resource leaks is not closing a response body for an HTTP request. There's a linter available to make it easier to catch this, so this enables that linter and fixes all the cases reported. This is almost all test cases, except for one production code path case in the throttler. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
3 tasks
dbussink
added a commit
to planetscale/vitess
that referenced
this pull request
Nov 30, 2022
One of the easy things to miss that can cause resource leaks is not closing a response body for an HTTP request. There's a linter available to make it easier to catch this, so this enables that linter and fixes all the cases reported. This is almost all test cases, except for one production code path case in the throttler. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
3 tasks
frouioui
pushed a commit
that referenced
this pull request
Nov 30, 2022
* Fix closing the body for HTTP requests (#11842) One of the easy things to miss that can cause resource leaks is not closing a response body for an HTTP request. There's a linter available to make it easier to catch this, so this enables that linter and fixes all the cases reported. This is almost all test cases, except for one production code path case in the throttler. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> * Always close body for HTTP requests (#10835) Not closing the body leads to leaking goroutines for the reader / writer of the body. Found when validating that tests don't leak goroutines (to ensure other things get closed properly, but these cases where also found). Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> * Fix remaining body close issues Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
frouioui
pushed a commit
that referenced
this pull request
Nov 30, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of the easy things to miss that can cause resource leaks is not closing a response body for an HTTP request.
There's a linter available to make it easier to catch this, so this enables that linter and fixes all the cases reported.
This is almost all test cases, except for one production code path case in the throttler.
Related Issue(s)
Fixes #11841
Checklist