BlockingStub returns iterator that cannot be closed
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
I use a blocking sub for a method that returns a stream of messages. The return type of it is `Iterator`. It turns out I cannot make grpc client to end the request (e.g. because of client failure). There are a number of cases where an open connection may stuck in client because of that
The implementation uses
`io.grpc.stub.ClientCalls#blockingServerStreamingCall(io.grpc.Channel, io.grpc.MethodDescriptor, io.grpc.CallOptions, ReqT)`
call, which in turn uses `BlockingResponseStream`. There is no way to reach the `io.grpc.ClientCall#cancel` method form the Iterator. Could be nice to wrap an Iterator or make it implement an interface in the similar way as done with ServerStreamObserver/ClientStreamObserver
The other approach could be to implement `AutoCloseable` from Java with this iterator
There is also a comment on the Iterator implementation class
```
// TODO(ejona86): determine how to allow ClientCall.cancel() in case of application error.
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.