aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httputil/reverseproxy_test.go
diff options
context:
space:
mode:
authorAndrew G. Morgan <agm@google.com>2020-05-04 17:50:17 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2020-05-05 03:40:39 +0000
commitb40c6580639beb1fd24bbf8cc50f4488c245c41b (patch)
treeddc040c8ae98f1568ad961e9997035761f2ae7a1 /src/net/http/httputil/reverseproxy_test.go
parent01a9cf8487df2b108f0dfd7060ff5ffbda972c3a (diff)
downloadgo-b40c6580639beb1fd24bbf8cc50f4488c245c41b.tar.gz
go-b40c6580639beb1fd24bbf8cc50f4488c245c41b.zip
net/http/httputil: don't use testing.T after test completes
This fixes a race condition where TestReverseProxyWebSocketCancelation appears to panic after otherwise passing. Fixes #38863 Change-Id: Ib89f4c40da879b92ac1fc5ed8b6e48da929e4a18 Reviewed-on: https://go-review.googlesource.com/c/go/+/232257 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/httputil/reverseproxy_test.go')
-rw-r--r--src/net/http/httputil/reverseproxy_test.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
index 6a3a1c54fc..764939fb0f 100644
--- a/src/net/http/httputil/reverseproxy_test.go
+++ b/src/net/http/httputil/reverseproxy_test.go
@@ -1224,13 +1224,22 @@ func TestReverseProxyWebSocketCancelation(t *testing.T) {
for i := 0; i < n; i++ {
if _, err := bufrw.WriteString(nthResponse(i)); err != nil {
- t.Errorf("Writing response #%d failed: %v", i, err)
+ select {
+ case <-triggerCancelCh:
+ default:
+ t.Errorf("Writing response #%d failed: %v", i, err)
+ }
+ return
}
bufrw.Flush()
time.Sleep(time.Second)
}
if _, err := bufrw.WriteString(terminalMsg); err != nil {
- t.Errorf("Failed to write terminal message: %v", err)
+ select {
+ case <-triggerCancelCh:
+ default:
+ t.Errorf("Failed to write terminal message: %v", err)
+ }
}
bufrw.Flush()
}))