Check if cc.conns == nil before reading cc.conns

This commit is contained in:
Menghan Li
2016-08-18 16:41:22 -07:00
parent 2e4cfe0fc5
commit f3ac95e6cd
2 changed files with 19 additions and 0 deletions

View File

@ -276,3 +276,18 @@ func TestInvokeCancel(t *testing.T) {
cc.Close()
server.stop()
}
// TestInvokeCancelClosedNonFail checks that a canceled non-failfast RPC
// on a closed client will terminate.
func TestInvokeCancelClosedNonFailFast(t *testing.T) {
server, cc := setUp(t, 0, math.MaxUint32)
var reply string
cc.Close()
req := "hello"
ctx, cancel := context.WithCancel(context.Background())
cancel()
if err := Invoke(ctx, "/foo/bar", &req, &reply, cc, FailFast(false)); err == nil {
t.Fatalf("canceled invoke on closed connection should fail")
}
server.stop()
}