@@ -499,7 +499,7 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
499
499
streamStatus = lifecycleManager .getShutdownStatus ();
500
500
}
501
501
try {
502
- cancelPing (lifecycleManager .getShutdownThrowable ());
502
+ cancelPing (lifecycleManager .getShutdownStatus ());
503
503
// Report status to the application layer for any open streams
504
504
connection ().forEachActiveStream (new Http2StreamVisitor () {
505
505
@ Override
@@ -593,13 +593,14 @@ protected boolean isGracefulShutdownComplete() {
593
593
*/
594
594
private void createStream (CreateStreamCommand command , ChannelPromise promise )
595
595
throws Exception {
596
- if (lifecycleManager .getShutdownThrowable () != null ) {
596
+ if (lifecycleManager .getShutdownStatus () != null ) {
597
597
command .stream ().setNonExistent ();
598
598
// The connection is going away (it is really the GOAWAY case),
599
599
// just terminate the stream now.
600
600
command .stream ().transportReportStatus (
601
601
lifecycleManager .getShutdownStatus (), RpcProgress .MISCARRIED , true , new Metadata ());
602
- promise .setFailure (lifecycleManager .getShutdownThrowable ());
602
+ promise .setFailure (InternalStatus .asRuntimeExceptionWithoutStacktrace (
603
+ lifecycleManager .getShutdownStatus (), null ));
603
604
return ;
604
605
}
605
606
@@ -852,19 +853,21 @@ private void sendPingFrameTraced(ChannelHandlerContext ctx, SendPingCommand msg,
852
853
public void operationComplete (ChannelFuture future ) throws Exception {
853
854
if (future .isSuccess ()) {
854
855
transportTracer .reportKeepAliveSent ();
855
- } else {
856
- Throwable cause = future .cause ();
857
- if (cause instanceof ClosedChannelException ) {
858
- cause = lifecycleManager .getShutdownThrowable ();
859
- if (cause == null ) {
860
- cause = Status .UNKNOWN .withDescription ("Ping failed but for unknown reason." )
861
- .withCause (future .cause ()).asException ();
862
- }
863
- }
864
- finalPing .failed (cause );
865
- if (ping == finalPing ) {
866
- ping = null ;
856
+ return ;
857
+ }
858
+ Throwable cause = future .cause ();
859
+ Status status = lifecycleManager .getShutdownStatus ();
860
+ if (cause instanceof ClosedChannelException ) {
861
+ if (status == null ) {
862
+ status = Status .UNKNOWN .withDescription ("Ping failed but for unknown reason." )
863
+ .withCause (future .cause ());
867
864
}
865
+ } else {
866
+ status = Utils .statusFromThrowable (cause );
867
+ }
868
+ finalPing .failed (status );
869
+ if (ping == finalPing ) {
870
+ ping = null ;
868
871
}
869
872
}
870
873
});
@@ -963,9 +966,9 @@ public boolean visit(Http2Stream stream) throws Http2Exception {
963
966
}
964
967
}
965
968
966
- private void cancelPing (Throwable t ) {
969
+ private void cancelPing (Status s ) {
967
970
if (ping != null ) {
968
- ping .failed (t );
971
+ ping .failed (s );
969
972
ping = null ;
970
973
}
971
974
}
0 commit comments