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
Panic with Go versions < 1.15.0 when reading (http.Response).Body #41071
Comments
There is a bug in your test
This is the fix
|
Thank you @davecheney, I'll file that and review the changes. The behavior you note precedes me (confirmed all the way back to v1.2.0) and I had yet to dig into it deep enough to understand all aspects of the test. I'm not sure I would have caught this specific issue for some time (I am still very new to Go). Regarding the issue I opened here and the difference in behavior between Go 1.14 and 1.15: do you know if Go 1.15's handling of the code within the |
Fair enough, and thank you for the pointer. I didn't realize it was that easy to learn the answer (#38095, 2d77d33). I also failed to realize the scope of your involvement with the project! It appears that I also misunderstood the backporting policy (lots of learning today). Based on what you've noted, it doesn't appear that the changes made in 12d02e7 and 2d77d33 for #38095 will be backported to Go 1.14. That said, thank you for your time, the pointers and your suggested fixes to the current faulty test. I'll go ahead and close this out. |
No worries, glad you’ve been able to solve the problem. |
CHANGES Apply fix provided by @davecheney in order to properly implement the RoundTripper interface's expected behavior: - return response and nil error OR - return nil and a non-nil error to explain failures to obtain a response I likely *over* explained this with doc comments, but I am still very much in "learning" mode here. REFERENCES - GH-46 - 2ce144f - 6db6217 - http://hassansin.github.io/Unit-Testing-http-client-in-Go - golang/go#41071 - golang/go#38095 - golang/go@2d77d33 - golang/go@12d02e7 - https://godoc.org/net/http#RoundTripper - https://godoc.org/net/http#Response - https://godoc.org/net/http#Response.Body
Overview
The steps below reproduce a panic with Go versions earlier than
1.15beta1
. If Go 1.15 has the correct behavior, should Go 1.14.x also behave the same?Go versions tested
Panics:
Does not panic:
Instructions
cd /tmp
git clone https://github.com/atc0005/go-teams-notify
git checkout go-panic-repro
docker run --rm -it -v `pwd`:`pwd` -w `pwd` golang:1.15.0 go test -v ./...
docker run --rm -it -v `pwd`:`pwd` -w `pwd` golang:1.14.7 go test -v ./...
Output
Passing
Failing
References
Changes that triggered the panic behavior
Apparent "fix" for the panic
The text was updated successfully, but these errors were encountered: