grpc / grpc/grpc-java

Throwing an exception from some StreamTracer methods hangs the RPC

Open
#7,373 10 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
12.1k
Forks
4k
Avg merge
2d 17h
Merged PRs (30d)
37

Description

### What version of gRPC-Java are you using?
Head

### What is your environment?
Android

### What did you expect to see?
If a client-implemented `ClientStreamTracer` method throws an exception, the RPC should fail.

### What did you see instead?
The RPC never completes (blocks forever or the future never completes, depending on stub type).

### Steps to reproduce the bug

I was able to reproduce this bug with both the `InProcessChannel` and Cronet transport implementations.

From grpc's `GrpcServerRuleTest`:

```

@Test
public void testTracer() throws Exception {
TestServiceImpl testService = new TestServiceImpl();

grpcServerRule1.getServiceRegistry().addService(testService);

SimpleServiceGrpc.SimpleServiceBlockingStub stub =
SimpleServiceGrpc.newBlockingStub(grpcServerRule1.getChannel());

SimpleRequest request = SimpleRequest.getDefaultInstance();

SimpleResponse resp =
stub.withInterceptors(
new ClientInterceptor() {
@Override
public ClientCall interceptCall(
MethodDescriptor method, CallOptions callOptions, Channel next) {
return next.newCall(
method,
callOptions.withStreamTracerFactory(
new ClientStreamTracer.Factory() {
@Override
public ClientStreamTracer newClientStreamTracer(
ClientStreamTracer.StreamInfo info, Metadata headers) {
return new ClientStreamTracer() {
@Override
public void streamClosed(Status status) {
throw new RuntimeException();
}
};
}
}));
}
})
.unaryRpc(request);
assertThat(resp).isEqualTo(SimpleResponse.getDefaultInstance());
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.