Skip to content

Commit 7e8bc47

Browse files
Mistobaanbradfitz
authored andcommitted
net/http: fix flaky test
Prevent idle transport on race condition. Fixes #7847 LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/96230044
1 parent fb39286 commit 7e8bc47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pkg/net/http/transport_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,8 +1553,10 @@ func TestTransportSocketLateBinding(t *testing.T) {
15531553
dialGate := make(chan bool, 1)
15541554
tr := &Transport{
15551555
Dial: func(n, addr string) (net.Conn, error) {
1556-
<-dialGate
1557-
return net.Dial(n, addr)
1556+
if <-dialGate {
1557+
return net.Dial(n, addr)
1558+
}
1559+
return nil, errors.New("manually closed")
15581560
},
15591561
DisableKeepAlives: false,
15601562
}
@@ -1589,7 +1591,7 @@ func TestTransportSocketLateBinding(t *testing.T) {
15891591
t.Fatalf("/foo came from conn %q; /bar came from %q instead", fooAddr, barAddr)
15901592
}
15911593
barRes.Body.Close()
1592-
dialGate <- true
1594+
dialGate <- false
15931595
}
15941596

15951597
// Issue 2184

0 commit comments

Comments
 (0)