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 #30599

Merged
merged 4 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,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 @@ -345,7 +346,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 @@ -695,6 +695,7 @@ 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 @@ -2607,11 +2607,13 @@ func (e *TiFlashSystemTableRetriever) initialize(sctx sessionctx.Context, tiflas
if err != nil {
return errors.Trace(err)
}
_, err = util.InternalHTTPClient().Do(req)
var tmp *http.Response
tmp, err = util.InternalHTTPClient().Do(req)
if err != nil {
sctx.GetSessionVars().StmtCtx.AppendWarning(err)
continue
}
defer terror.Call(tmp.Body.Close)
e.instanceInfos = append(e.instanceInfos, tiflashInstanceInfo{
id: id,
url: url,
Expand Down