Skip to content

Commit

Permalink
Enhance server-side isCancelled comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ejona86 committed Mar 21, 2023
1 parent 836541d commit fe2f287
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ public void unaryEcho(EchoRequest request, StreamObserver<EchoResponse> response
Context currentContext = Context.current();
// Let's start a multi-part operation. We can check cancellation periodically.
for (int i = 0; i < 10; i++) {
// serverCallStreamObserver.isCancelled() would be equivalent here.
// ServerCallStreamObserver.isCancelled() returns true only if the RPC is cancelled.
// Context.isCancelled() is similar, but also returns true when the RPC completes normally.
// It doesn't matter which API is used here.
if (currentContext.isCancelled()) {
System.out.println("Unary RPC cancelled");
responseObserver.onError(
Expand Down

0 comments on commit fe2f287

Please sign in to comment.