Skip to content

Commit

Permalink
Merge pull request etcd-io#17634 from callthingsoff/httpresponse_clos…
Browse files Browse the repository at this point in the history
…e_after_read

all: call Close() after reading http.Response.Body
  • Loading branch information
ahrtr committed Mar 25, 2024
2 parents 7f9011a + bc31162 commit e4448c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/lock/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func write(key string, value string, version int64) error {
if err != nil {
log.Fatalf("failed to read request body: %s", err)
}
httpResp.Body.Close()

resp := new(response)
err = json.Unmarshal(respBytes, resp)
Expand Down
1 change: 1 addition & 0 deletions server/etcdserver/api/etcdhttp/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestNewPeerHandlerOnRaftPrefix(t *testing.T) {
if err != nil {
t.Fatalf("unexpected io.ReadAll error: %v", err)
}
resp.Body.Close()
if w := "test data"; string(body) != w {
t.Errorf("#%d: body = %s, want %s", i, body, w)
}
Expand Down

0 comments on commit e4448c4

Please sign in to comment.