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

etcdserver: close response body when getting cluster information #5120

Merged
merged 1 commit into from
Apr 19, 2016

Conversation

magicwang-cn
Copy link
Contributor

Fixes #5119

@heyitsanthony
Copy link
Contributor

Why not just put a resp.Body.Close() before this line: https://github.com/coreos/etcd/blob/master/etcdserver/cluster_util.go#L76 ? Creating a closure seems like overkill...

Also the commit title should to be prefixed by the package name like etcdserver: close response body when getting cluster information

@magicwang-cn
Copy link
Contributor Author

@heyitsanthony thanks for your review. i think it is more safer to use (defer) to clean unused resource, right? yeah. the commit should be clear

@magicwang-cn magicwang-cn changed the title code fix for closing response body etcdserver: close response body when getting cluster information Apr 19, 2016
@heyitsanthony
Copy link
Contributor

heyitsanthony commented Apr 19, 2016

@magicwang-cn No, it's not safer. It's more complicated: semantically, lexically, and cyclomatically. The defer only buys a Close if ReadAll panics, but there's no recover, so it doesn't matter if the resource is closed anyway. Where's the additional safety, exactly?

@magicwang-cn
Copy link
Contributor Author

yeah, you are right.:)

but there's no recover, so it doesn't matter if the resource is closed anyway

@heyitsanthony
Copy link
Contributor

lgtm

@xiang90 xiang90 merged commit d16628b into etcd-io:master Apr 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants