corefx properly cancel server stream from client for session events

This commit is contained in:
Blake J. Harnden 2019-05-31 16:53:16 -07:00
parent b075181796
commit 43e18d820f

View file

@ -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);
}