Skip to content

Conversation

JmPotato
Copy link
Member

Signed-off-by: JmPotato ghzpotato@gmail.com

What problem does this PR solve?

According to the overview of package "net/http", the client must close the response body when finished with it. This could be detected by:

golangci-lint run -E bodyclose

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test

Release note

Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot ti-chi-bot requested review from disksing and rleungx May 11, 2021 09:10
@@ -286,6 +286,7 @@ func (h *schedulerHandler) redirectSchedulerDelete(name, schedulerName string) e
if err != nil {
return err
}
defer resp.Body.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closed in doDelete?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@codecov
Copy link

codecov bot commented May 11, 2021

Codecov Report

Merging #3666 (af917aa) into master (bf0e891) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3666      +/-   ##
==========================================
+ Coverage   74.78%   74.82%   +0.03%     
==========================================
  Files         245      245              
  Lines       24237    24238       +1     
==========================================
+ Hits        18126    18136      +10     
+ Misses       4508     4498      -10     
- Partials     1603     1604       +1     
Flag Coverage Δ
unittests 74.82% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/server.go 72.85% <100.00%> (+0.04%) ⬆️
server/schedule/region_scatterer.go 83.72% <0.00%> (-4.66%) ⬇️
pkg/dashboard/adapter/manager.go 79.78% <0.00%> (-3.20%) ⬇️
server/schedulers/utils.go 93.63% <0.00%> (-1.28%) ⬇️
server/election/leadership.go 85.88% <0.00%> (-1.18%) ⬇️
server/tso/tso.go 70.11% <0.00%> (-1.15%) ⬇️
server/grpc_service.go 47.28% <0.00%> (-0.80%) ⬇️
client/base_client.go 82.47% <0.00%> (-0.52%) ⬇️
client/client.go 71.54% <0.00%> (-0.28%) ⬇️
server/schedule/operator/step.go 69.10% <0.00%> (+0.66%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf0e891...af917aa. Read the comment docs.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
server/server.go Outdated
@@ -1337,6 +1337,7 @@ func (s *Server) ReplicateFileToAllMembers(ctx context.Context, name string, dat
log.Warn("failed to replicate file", zap.String("name", name), zap.String("member", member.GetName()), errs.ZapError(err))
return errs.ErrSendRequest.Wrap(err).GenWithStackByCause()
}
defer res.Body.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about directly close instead of using defer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. PTAL again!

JmPotato added 2 commits May 11, 2021 17:56
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 11, 2021
@JmPotato JmPotato added the require-LGT1 Indicates that the PR requires an LGTM. label May 11, 2021
@JmPotato
Copy link
Member Author

/merge

@ti-chi-bot
Copy link
Member

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 0fd4529

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 11, 2021
@JmPotato JmPotato added the component/misc Some other things. label May 11, 2021
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ti-chi-bot ti-chi-bot merged commit 1faef48 into tikv:master May 11, 2021
Yisaer pushed a commit to Yisaer/pd that referenced this pull request May 14, 2021
* Close the response body when finished with it

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Remove a duplicate body close

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Address the comment

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Close the body immediately if there is no read

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
ti-chi-bot added a commit that referenced this pull request May 14, 2021
* change

Signed-off-by: yisaer <disxiaofei@163.com>

* fix go.sum

Signed-off-by: yisaer <disxiaofei@163.com>

* add comment

Signed-off-by: yisaer <disxiaofei@163.com>

* remove todo

Signed-off-by: yisaer <disxiaofei@163.com>

* fix test

Signed-off-by: yisaer <disxiaofei@163.com>

* add test

Signed-off-by: yisaer <disxiaofei@163.com>

* address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

* address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

* fix race

Signed-off-by: yisaer <disxiaofei@163.com>

* fix test

Signed-off-by: yisaer <disxiaofei@163.com>

address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

* fix race

Signed-off-by: yisaer <disxiaofei@163.com>

* *: close the response body when finished with it (#3666)

* Close the response body when finished with it

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Remove a duplicate body close

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Address the comment

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Close the body immediately if there is no read

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>

* scheduler: replace `move-hot-read-peer` with `move-hot-read-leader` (#3657)

* fix

Signed-off-by: lhy1024 <admin@liudos.us>

* address comment

Signed-off-by: lhy1024 <admin@liudos.us>

* address comment

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>

* *: clean up useless parameters (#3667)

* Clean up useless parameters

Signed-off-by: JmPotato <ghzpotato@gmail.com>

* Define some const variables

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ShuNing <nolouch@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>

* dashboard: Update to TiDB Dashboard v2021.05.12.1 (#3670)

* Update to TiDB Dashboard v2021.04.16.1

Signed-off-by: Suhaha <jklopsdfw@gmail.com>

* Update to TiDB Dashboard v2021.05.12.1

Signed-off-by: Suhaha <jklopsdfw@gmail.com>

Co-authored-by: 混沌DM <hundundm@gmail.com>

* address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

* address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

* address the comment

Signed-off-by: yisaer <disxiaofei@163.com>

Co-authored-by: JmPotato <ghzpotato@gmail.com>
Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Co-authored-by: lhy1024 <admin@liudos.us>
Co-authored-by: ShuNing <nolouch@gmail.com>
Co-authored-by: Suhaha <jklopsdfw@gmail.com>
Co-authored-by: 混沌DM <hundundm@gmail.com>
@JmPotato JmPotato deleted the fix_body_close branch July 5, 2021 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/misc Some other things. require-LGT1 Indicates that the PR requires an LGTM. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants