Throwing an exception from some StreamTracer methods hangs the RPC
- 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
Assessment
This issue has not been assessed yet.