From: Damien Neil Date: Fri, 22 Mar 2024 21:33:50 +0000 (-0700) Subject: net/http: ensure server handler is done in TestServerNoWriteTimeout X-Git-Tag: go1.23rc1~791 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8aeec7c5b0c630bb68798bc4b5fc7531b4d26694;p=gostls13.git 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov Auto-Submit: Damien Neil --- 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()) } }