-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement body.Close checker #6646
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with adding this, just a couple of specific comments inline.
rest/utilities_testing_user.go
Outdated
@@ -37,6 +37,7 @@ func MakeUser(t *testing.T, httpClient *http.Client, serverURL, username, passwo | |||
if err != nil { | |||
return true, err, resp | |||
} | |||
assert.NoError(t, resp.Body.Close()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for the code outside the retry loop to read the body after it has already been closed? (47-51)
I think we can also drop the outer Body.Close() if we ensure the unclosed body doesn't leak out of the retry loop.
@@ -2287,6 +2287,7 @@ func TestEventuallyReachableOIDCClient(t *testing.T) { | |||
request := createOIDCRequest(t, sessionEndpoint, token) | |||
response, err := http.DefaultClient.Do(request) | |||
require.NoError(t, err, "Error sending request with bearer token") | |||
defer func() { assert.NoError(t, response.Body.Close()) }() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't each response body need closing? The defer will only get one of the 3 here
* implement body.Close * Add some missing asserts, simplify MakeUser * add missing error check
There were no production code that was missing body.Close() but there was a lot missing in tests. This is a small resource leak.
Pre-review checklist
fmt.Print
,log.Print
, ...)base.UD(docID)
,base.MD(dbName)
)docs/api
Integration Tests
GSI=true,xattrs=true
https://jenkins.sgwdev.com/job/SyncGateway-Integration/2263/