corefx properly cancel server stream from client for session events
This commit is contained in:
parent
b075181796
commit
43e18d820f
1 changed files with 34 additions and 28 deletions
|
@ -1129,6 +1129,8 @@ public class CoreGrpcClient implements ICoreClient {
|
|||
|
||||
Iterator<CoreProto.Event> events = blockingStub.events(request);
|
||||
executorService.submit(() -> {
|
||||
Context.CancellableContext context = Context.current().withCancellation();
|
||||
context.run(() -> {
|
||||
try {
|
||||
while (handlingEvents) {
|
||||
CoreProto.Event event = events.next();
|
||||
|
@ -1158,8 +1160,12 @@ public class CoreGrpcClient implements ICoreClient {
|
|||
}
|
||||
} catch (StatusRuntimeException ex) {
|
||||
logger.error("error handling session events", ex);
|
||||
} finally {
|
||||
context.cancel(null);
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (StatusRuntimeException ex) {
|
||||
throw new IOException("setup event handlers error", ex);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue