rpc: fix defer in test (#24490)

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
s7v7nislands 2022-03-11 23:24:13 +08:00 committed by GitHub
parent 8f66ea3786
commit 496f05cf52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,7 +134,7 @@ func TestServerShortLivedConn(t *testing.T) {
if err != nil { if err != nil {
t.Fatal("can't dial:", err) t.Fatal("can't dial:", err)
} }
defer conn.Close()
conn.SetDeadline(deadline) conn.SetDeadline(deadline)
// Write the request, then half-close the connection so the server stops reading. // Write the request, then half-close the connection so the server stops reading.
conn.Write([]byte(request)) conn.Write([]byte(request))
@ -142,6 +142,8 @@ func TestServerShortLivedConn(t *testing.T) {
// Now try to get the response. // Now try to get the response.
buf := make([]byte, 2000) buf := make([]byte, 2000)
n, err := conn.Read(buf) n, err := conn.Read(buf)
conn.Close()
if err != nil { if err != nil {
t.Fatal("read error:", err) t.Fatal("read error:", err)
} }