MCPcopy Create free account
hub / github.com/grpc/grpc-java / cancel

Method cancel

core/src/main/java/io/grpc/internal/DelayedStream.java:315–341  ·  view source on GitHub ↗
(final Status reason)

Source from the content-addressed store, hash-verified

313
314 // When this method returns, passThrough is guaranteed to be true
315 @Override
316 public void cancel(final Status reason) {
317 checkState(listener != null, "May only be called after start");
318 checkNotNull(reason, "reason");
319 boolean delegateToRealStream = true;
320 synchronized (this) {
321 // If realStream != null, then either setStream() or cancel() has been called
322 if (realStream == null) {
323 setRealStream(NoopClientStream.INSTANCE);
324 delegateToRealStream = false;
325 error = reason;
326 }
327 }
328 if (delegateToRealStream) {
329 delayOrExecute(new Runnable() {
330 @Override
331 public void run() {
332 realStream.cancel(reason);
333 }
334 });
335 } else {
336 drainPendingCalls();
337 onEarlyCancellation(reason);
338 // Note that listener is a DelayedStreamListener
339 listener.closed(reason, RpcProgress.PROCESSED, new Metadata());
340 }
341 }
342
343 protected void onEarlyCancellation(Status reason) {
344 }

Callers

nothing calls this directly

Calls 6

setRealStreamMethod · 0.95
delayOrExecuteMethod · 0.95
drainPendingCallsMethod · 0.95
onEarlyCancellationMethod · 0.95
checkNotNullMethod · 0.80
closedMethod · 0.65

Tested by

no test coverage detected