@@ -200,9 +200,9 @@ public void flush(ChannelHandlerContext ctx) {
200
200
encoder .flowController ().writePendingBytes ();
201
201
ctx .flush ();
202
202
} catch (Http2Exception e ) {
203
- onError (ctx , e );
203
+ onError (ctx , true , e );
204
204
} catch (Throwable cause ) {
205
- onError (ctx , connectionError (INTERNAL_ERROR , cause , "Error flushing" ));
205
+ onError (ctx , true , connectionError (INTERNAL_ERROR , cause , "Error flushing" ));
206
206
}
207
207
}
208
208
@@ -254,7 +254,7 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
254
254
byteDecoder .decode (ctx , in , out );
255
255
}
256
256
} catch (Throwable e ) {
257
- onError (ctx , e );
257
+ onError (ctx , false , e );
258
258
}
259
259
}
260
260
@@ -389,7 +389,7 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
389
389
try {
390
390
decoder .decodeFrame (ctx , in , out );
391
391
} catch (Throwable e ) {
392
- onError (ctx , e );
392
+ onError (ctx , false , e );
393
393
}
394
394
}
395
395
}
@@ -538,7 +538,7 @@ void channelReadComplete0(ChannelHandlerContext ctx) throws Exception {
538
538
public void exceptionCaught (ChannelHandlerContext ctx , Throwable cause ) throws Exception {
539
539
if (getEmbeddedHttp2Exception (cause ) != null ) {
540
540
// Some exception in the causality chain is an Http2Exception - handle it.
541
- onError (ctx , cause );
541
+ onError (ctx , false , cause );
542
542
} else {
543
543
super .exceptionCaught (ctx , cause );
544
544
}
@@ -604,17 +604,17 @@ public void operationComplete(ChannelFuture future) throws Exception {
604
604
* Central handler for all exceptions caught during HTTP/2 processing.
605
605
*/
606
606
@ Override
607
- public void onError (ChannelHandlerContext ctx , Throwable cause ) {
607
+ public void onError (ChannelHandlerContext ctx , boolean outbound , Throwable cause ) {
608
608
Http2Exception embedded = getEmbeddedHttp2Exception (cause );
609
609
if (isStreamError (embedded )) {
610
- onStreamError (ctx , cause , (StreamException ) embedded );
610
+ onStreamError (ctx , outbound , cause , (StreamException ) embedded );
611
611
} else if (embedded instanceof CompositeStreamException ) {
612
612
CompositeStreamException compositException = (CompositeStreamException ) embedded ;
613
613
for (StreamException streamException : compositException ) {
614
- onStreamError (ctx , cause , streamException );
614
+ onStreamError (ctx , outbound , cause , streamException );
615
615
}
616
616
} else {
617
- onConnectionError (ctx , cause , embedded );
617
+ onConnectionError (ctx , outbound , cause , embedded );
618
618
}
619
619
ctx .flush ();
620
620
}
@@ -633,11 +633,13 @@ protected boolean isGracefulShutdownComplete() {
633
633
* streams are closed, the connection is shut down.
634
634
*
635
635
* @param ctx the channel context
636
+ * @param outbound {@code true} if the error was caused by an outbound operation.
636
637
* @param cause the exception that was caught
637
638
* @param http2Ex the {@link Http2Exception} that is embedded in the causality chain. This may
638
639
* be {@code null} if it's an unknown exception.
639
640
*/
640
- protected void onConnectionError (ChannelHandlerContext ctx , Throwable cause , Http2Exception http2Ex ) {
641
+ protected void onConnectionError (ChannelHandlerContext ctx , boolean outbound ,
642
+ Throwable cause , Http2Exception http2Ex ) {
641
643
if (http2Ex == null ) {
642
644
http2Ex = new Http2Exception (INTERNAL_ERROR , cause .getMessage (), cause );
643
645
}
@@ -659,11 +661,12 @@ protected void onConnectionError(ChannelHandlerContext ctx, Throwable cause, Htt
659
661
* stream.
660
662
*
661
663
* @param ctx the channel context
664
+ * @param outbound {@code true} if the error was caused by an outbound operation.
662
665
* @param cause the exception that was caught
663
666
* @param http2Ex the {@link StreamException} that is embedded in the causality chain.
664
667
*/
665
- protected void onStreamError (ChannelHandlerContext ctx , @ SuppressWarnings ( "unused" ) Throwable cause ,
666
- StreamException http2Ex ) {
668
+ protected void onStreamError (ChannelHandlerContext ctx , boolean outbound ,
669
+ @ SuppressWarnings ( "unused" ) Throwable cause , StreamException http2Ex ) {
667
670
final int streamId = http2Ex .streamId ();
668
671
Http2Stream stream = connection ().stream (streamId );
669
672
@@ -692,7 +695,7 @@ protected void onStreamError(ChannelHandlerContext ctx, @SuppressWarnings("unuse
692
695
try {
693
696
handleServerHeaderDecodeSizeError (ctx , stream );
694
697
} catch (Throwable cause2 ) {
695
- onError (ctx , connectionError (INTERNAL_ERROR , cause2 , "Error DecodeSizeError" ));
698
+ onError (ctx , outbound , connectionError (INTERNAL_ERROR , cause2 , "Error DecodeSizeError" ));
696
699
}
697
700
}
698
701
}
@@ -867,13 +870,13 @@ private void processRstStreamWriteResult(ChannelHandlerContext ctx, Http2Stream
867
870
closeStream (stream , future );
868
871
} else {
869
872
// The connection will be closed and so no need to change the resetSent flag to false.
870
- onConnectionError (ctx , future .cause (), null );
873
+ onConnectionError (ctx , true , future .cause (), null );
871
874
}
872
875
}
873
876
874
877
private void closeConnectionOnError (ChannelHandlerContext ctx , ChannelFuture future ) {
875
878
if (!future .isSuccess ()) {
876
- onConnectionError (ctx , future .cause (), null );
879
+ onConnectionError (ctx , true , future .cause (), null );
877
880
}
878
881
}
879
882
0 commit comments