grpc / grpc/grpc-java

Throwing an exception from some StreamTracer methods hangs the RPC

Aperta
#7,373 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

### 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());
}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione di GrpcServerRuleTest.testTracer e traccia come viene gestita l’eccezione di ClientStreamTracer.streamClosed per lo stub bloccante. Confronta il comportamento nelle implementazioni del trasporto InProcessChannel e Cronet. Il lavoro è completato quando l’RPC fallisce invece di bloccarsi per sempre o lasciare il future incompleto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.