Skip to content

Commit 8107444

Browse files
committed
remove extra variable
1 parent a21fcc4 commit 8107444

File tree

2 files changed

+5
-78
lines changed

2 files changed

+5
-78
lines changed

stream.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ type clientStream struct {
542542

543543
sentLast bool // sent an end stream
544544

545-
recvFirstMsg bool // received first msg
546-
547545
methodConfig *MethodConfig
548546

549547
ctx context.Context // the application's context, wrapped by stats/tracing
@@ -1137,17 +1135,14 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) {
11371135
return statusErr
11381136
}
11391137
// received no msg and status ok for non-server streaming rpcs.
1140-
if !cs.desc.ServerStreams && !cs.recvFirstMsg {
1138+
if !cs.desc.ServerStreams {
11411139
return status.Errorf(codes.Internal, "cardinality violation: received no response message from non-streaming RPC")
11421140
}
11431141
return io.EOF // indicates successful end of stream.
11441142
}
11451143

11461144
return toRPCErr(err)
11471145
}
1148-
if !cs.desc.ServerStreams {
1149-
cs.recvFirstMsg = true
1150-
}
11511146
if a.trInfo != nil {
11521147
a.mu.Lock()
11531148
if a.trInfo.tr != nil {
@@ -1483,6 +1478,10 @@ func (as *addrConnStream) RecvMsg(m any) (err error) {
14831478
if statusErr := as.transportStream.Status().Err(); statusErr != nil {
14841479
return statusErr
14851480
}
1481+
// received no msg and status ok for non-server streaming rpcs.
1482+
if !as.desc.ServerStreams {
1483+
return status.Errorf(codes.Internal, "cardinality violation: received no response message from non-streaming RPC")
1484+
}
14861485
return io.EOF // indicates successful end of stream.
14871486
}
14881487
return toRPCErr(err)

test/end2end_test.go

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,42 +3736,6 @@ func (s) TestClientStreaming_ReturnErrorAfterSendAndClose(t *testing.T) {
37363736
}
37373737
}
37383738

3739-
// Tests for a successful RPC, client will receive io.EOF for second call to RecvMsg().
3740-
func (s) TestClientStreaming_ClientCallRecvMsgTwice(t *testing.T) {
3741-
ss := stubserver.StubServer{
3742-
StreamingInputCallF: func(stream testgrpc.TestService_StreamingInputCallServer) error {
3743-
if err := stream.SendAndClose(&testpb.StreamingInputCallResponse{}); err != nil {
3744-
t.Errorf("stream.SendAndClose(_) = %v, want <nil>", err)
3745-
}
3746-
return nil
3747-
},
3748-
}
3749-
if err := ss.Start(nil); err != nil {
3750-
t.Fatal("Error starting server:", err)
3751-
}
3752-
defer ss.Stop()
3753-
3754-
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
3755-
defer cancel()
3756-
stream, err := ss.Client.StreamingInputCall(ctx)
3757-
if err != nil {
3758-
t.Fatalf(".StreamingInputCall(_) = _, %v, want <nil>", err)
3759-
}
3760-
if err := stream.Send(&testpb.StreamingInputCallRequest{}); err != nil {
3761-
t.Fatalf("stream.Send(_) = %v, want <nil>", err)
3762-
}
3763-
if err := stream.CloseSend(); err != nil {
3764-
t.Fatalf("stream.CloseSend() = %v, want <nil>", err)
3765-
}
3766-
resp := new(testpb.StreamingInputCallResponse)
3767-
if err := stream.RecvMsg(resp); err != nil {
3768-
t.Fatalf("stream.RecvMsg() = %v , want <nil>", err)
3769-
}
3770-
if err := stream.RecvMsg(resp); err != io.EOF {
3771-
t.Fatalf("stream.RecvMsg() = %v, want error %s", err, io.EOF)
3772-
}
3773-
}
3774-
37753739
// Tests that a client receives a cardinality violation error for unary
37763740
// RPCs if the server doesn't send a message before returning status OK.
37773741
func (s) TestUnaryRPC_ServerSendsOnlyTrailersWithOK(t *testing.T) {
@@ -3816,42 +3780,6 @@ func (s) TestUnaryRPC_ServerSendsOnlyTrailersWithOK(t *testing.T) {
38163780
}
38173781
}
38183782

3819-
// Tests for a successful unary RPC, client will receive io.EOF for second call to RecvMsg().
3820-
func (s) TestUnaryRPC_ClientCallRecvMsgTwice(t *testing.T) {
3821-
e := tcpTLSEnv
3822-
te := newTest(t, e)
3823-
defer te.tearDown()
3824-
3825-
te.startServer(&testServer{security: e.security})
3826-
3827-
cc := te.clientConn()
3828-
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
3829-
defer cancel()
3830-
3831-
desc := &grpc.StreamDesc{
3832-
StreamName: "UnaryCall",
3833-
ServerStreams: false,
3834-
ClientStreams: false,
3835-
}
3836-
stream, err := cc.NewStream(ctx, desc, "/grpc.testing.TestService/UnaryCall")
3837-
if err != nil {
3838-
t.Fatalf("cc.NewStream() failed unexpectedly: %v", err)
3839-
}
3840-
3841-
if err := stream.SendMsg(&testpb.SimpleRequest{}); err != nil {
3842-
t.Fatalf("stream.SendMsg(_) = %v, want <nil>", err)
3843-
}
3844-
3845-
resp := &testpb.SimpleResponse{}
3846-
if err := stream.RecvMsg(resp); err != nil {
3847-
t.Fatalf("stream.RecvMsg() = %v , want <nil>", err)
3848-
}
3849-
3850-
if err = stream.RecvMsg(resp); err != io.EOF {
3851-
t.Fatalf("stream.RecvMsg() = %v, want error %s", err, io.EOF)
3852-
}
3853-
}
3854-
38553783
func (s) TestExceedMaxStreamsLimit(t *testing.T) {
38563784
for _, e := range listTestEnv() {
38573785
testExceedMaxStreamsLimit(t, e)

0 commit comments

Comments
 (0)