Skip to content
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

*: fix some http connection leaks found by lint check #30570

Merged
merged 3 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/explaintest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ func (t *tester) create(tableName string, qText string) error {
if err != nil {
return err
}
defer resp.Body.Close()

js, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func doRequest(ctx context.Context, addrs []string, route, method string, body i
}
})
if err == nil {
defer terror.Call(res.Body.Close)
bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
Expand All @@ -344,7 +345,6 @@ func doRequest(ctx context.Context, addrs []string, route, method string, body i
bodyBytes = nil
}
}
terror.Log(res.Body.Close())
return bodyBytes, err
}
}
Expand Down Expand Up @@ -694,6 +694,8 @@ func (is *InfoSyncer) getPrometheusAddr() (string, error) {
if err != nil {
return "", err
}
defer terror.Call(resp.Body.Close)

var metricStorage metricStorage
dec := json.NewDecoder(resp.Body)
err = dec.Decode(&metricStorage)
Expand Down
4 changes: 3 additions & 1 deletion executor/infoschema_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -2264,11 +2264,13 @@ func (e *TiFlashSystemTableRetriever) initialize(sctx sessionctx.Context, tiflas
if err != nil {
return errors.Trace(err)
}
_, err = util.InternalHTTPClient().Do(req)
var r *http.Response
r, err = util.InternalHTTPClient().Do(req)
if err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
continue
}
defer terror.Call(r.Body.Close)
e.instanceInfos = append(e.instanceInfos, tiflashInstanceInfo{
id: id,
url: url,
Expand Down