@@ -197,9 +197,6 @@ public final void halfClose() {
197197 @ Override
198198 public final void cancel (Status reason ) {
199199 Preconditions .checkArgument (!reason .isOk (), "Should not cancel with OK status" );
200- if (cancelled || transportState ().isListenerClosed ()) {
201- return ;
202- }
203200 cancelled = true ;
204201 abstractClientStreamSink ().cancel (reason );
205202 }
@@ -254,9 +251,7 @@ protected TransportState(
254251 }
255252 }
256253
257- protected final boolean isListenerClosed () {
258- return listenerClosed ;
259- }
254+
260255
261256 private void setFullStreamDecompression (boolean fullStreamDecompression ) {
262257 this .fullStreamDecompression = fullStreamDecompression ;
@@ -398,16 +393,16 @@ protected void inboundTrailersReceived(Metadata trailers, Status status) {
398393 * method must be called from the transport thread.
399394 *
400395 * @param status the new status to set
401- * @param stopDelivery if {@code true}, interrupts any further delivery of inbound messages that
396+ * @param cancelled if {@code true}, interrupts any further delivery of inbound messages that
402397 * may already be queued up in the deframer. If {@code false}, the listener will be
403398 * notified immediately after all currently completed messages in the deframer have been
404399 * delivered to the application.
405400 * @param trailers new instance of {@code Trailers}, either empty or those returned by the
406401 * server
407402 */
408- public final void transportReportStatus (final Status status , boolean stopDelivery ,
403+ public final void transportReportStatus (final Status status , boolean cancelled ,
409404 final Metadata trailers ) {
410- transportReportStatus (status , RpcProgress .PROCESSED , stopDelivery , trailers );
405+ transportReportStatus (status , RpcProgress .PROCESSED , cancelled , trailers );
411406 }
412407
413408 /**
@@ -418,7 +413,7 @@ public final void transportReportStatus(final Status status, boolean stopDeliver
418413 * @param rpcProgress RPC progress that the
419414 * {@link ClientStreamListener#closed(Status, RpcProgress, Metadata)}
420415 * will receive
421- * @param stopDelivery if {@code true}, interrupts any further delivery of inbound messages that
416+ * @param cancelled if {@code true}, interrupts any further delivery of inbound messages that
422417 * may already be queued up in the deframer and overrides any previously queued status.
423418 * If {@code false}, the listener will be notified immediately after all currently
424419 * completed messages in the deframer have been delivered to the application.
@@ -428,30 +423,33 @@ public final void transportReportStatus(final Status status, boolean stopDeliver
428423 public final void transportReportStatus (
429424 final Status status ,
430425 final RpcProgress rpcProgress ,
431- boolean stopDelivery ,
426+ boolean cancelled ,
432427 final Metadata trailers ) {
433428 checkNotNull (status , "status" );
434429 checkNotNull (trailers , "trailers" );
435- // If stopDelivery , we continue in case previous invocation is waiting for stall
436- if (statusReported && !stopDelivery ) {
430+ // If cancelled , we continue in case previous invocation is waiting for stall
431+ if (statusReported && !cancelled ) {
437432 return ;
438433 }
439434 statusReported = true ;
440435 statusReportedIsOk = status .isOk ();
436+ if (cancelled ) {
437+ statsTraceCtx .clientCancelled (status );
438+ }
441439 onStreamDeallocated ();
442440
443441 if (deframerClosed ) {
444442 deframerClosedTask = null ;
445- closeListener (status , rpcProgress , trailers , stopDelivery );
443+ closeListener (status , rpcProgress , trailers );
446444 } else {
447445 deframerClosedTask =
448446 new Runnable () {
449447 @ Override
450448 public void run () {
451- closeListener (status , rpcProgress , trailers , stopDelivery );
449+ closeListener (status , rpcProgress , trailers );
452450 }
453451 };
454- closeDeframer (stopDelivery );
452+ closeDeframer (cancelled );
455453 }
456454 }
457455
@@ -461,12 +459,9 @@ public void run() {
461459 * @throws IllegalStateException if the call has not yet been started.
462460 */
463461 private void closeListener (
464- Status status , RpcProgress rpcProgress , Metadata trailers , boolean stopDelivery ) {
462+ Status status , RpcProgress rpcProgress , Metadata trailers ) {
465463 if (!listenerClosed ) {
466464 listenerClosed = true ;
467- if (stopDelivery ) {
468- statsTraceCtx .clientCancelled (status );
469- }
470465 statsTraceCtx .streamClosed (status );
471466 if (getTransportTracer () != null ) {
472467 getTransportTracer ().reportStreamClosed (status .isOk ());
0 commit comments