aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2024-03-22 14:33:50 -0700
committerDamien Neil <dneil@google.com>2024-03-22 23:15:35 +0000
commit8aeec7c5b0c630bb68798bc4b5fc7531b4d26694 (patch)
treebbca42f43b4d8a20919740716a7d172d1913c185 /src/net/http
parent5f5b20c4268c1a3aa6a3b132aeede6dc82adf344 (diff)
downloadgo-8aeec7c5b0c630bb68798bc4b5fc7531b4d26694.tar.xz
net/http: ensure server handler is done in TestServerNoWriteTimeout
Surprisingly, newClientServerTest doesn't ensure that server handlers are done in its t.Cleanup function. This test's handler can outlive the test and attempt to log after the test has completed, causing race detector failures. Add an explicit call to Server.Shutdown to ensure the handler has completed. We should also probably add a Shutdown to clientServerTest.close, but that's a larger change; this fixes the immediate problem. Change-Id: Ibe81b4b382c9c8a920b0ff5f76dea6afe69b10f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/573895 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/serve_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
index 8998f38367..94b8bdcc2e 100644
--- a/src/net/http/serve_test.go
+++ b/src/net/http/serve_test.go
@@ -922,6 +922,10 @@ func testServerNoWriteTimeout(t *testing.T, mode testMode) {
if n != 1<<20 || err != nil {
t.Errorf("client read response body: %d, %v", n, err)
}
+ // This shutdown really should be automatic, but it isn't right now.
+ // Shutdown (rather than Close) ensures the handler is done before we return.
+ res.Body.Close()
+ cst.ts.Config.Shutdown(context.Background())
}
}