From a49b0302d0e1d97b67a5f3f3beceafdcbc4c2ef0 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Wed, 19 Nov 2025 11:25:49 -0800 Subject: [PATCH] net/http: correctly close fake net.Conns Fix an inverted test in fakeNetConn.Close that caused closing a connection to not break the other half of the connection. Change-Id: I4e53f78402f8e503c749d57f294a4524abdccfb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/722220 Reviewed-by: Nicholas Husin Reviewed-by: Nicholas Husin Auto-Submit: Damien Neil LUCI-TryBot-Result: Go LUCI --- src/net/http/netconn_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/net/http/netconn_test.go b/src/net/http/netconn_test.go index 52b8069f8b..c5fd61289f 100644 --- a/src/net/http/netconn_test.go +++ b/src/net/http/netconn_test.go @@ -180,9 +180,10 @@ func (c *fakeNetConn) Close() error { c.loc.unlock() // Remote half of the connection reads EOF after reading any remaining data. c.rem.lock() - if c.rem.readErr != nil { + if c.rem.readErr == nil { c.rem.readErr = io.EOF } + c.rem.writeErr = net.ErrClosed c.rem.unlock() if c.autoWait { synctest.Wait() -- 2.52.0