BlockingStub returns iterator that cannot be closed
- Dominant language
- Java
- Stars
- 12.1k
- Forks
- 4k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 37
Description
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.
```
Contributor guide
Assessment
This issue has not been assessed yet.