BlockingStub returns iterator that cannot be closed
- Lenguaje dominante
- Java
- Estrellas
- 12.1k
- Forks
- 4k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 37
Descripción
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.
```
Guía de contribución
Línea de trabajo
Comienza con io.grpc.stub.ClientCalls#blockingServerStreamingCall y la implementación de BlockingResponseStream; después, lee el TODO sobre permitir ClientCall.cancel() en caso de error de la aplicación. Compara los enfoques propuestos de wrapper de Iterator, interface y AutoCloseable; se considera terminado cuando un resultado de streaming bloqueante puede exponer la cancelación de la solicitud sin romper su comportamiento existente de Iterator.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100