use of io.netty.handler.codec.http2.Http2Exception.StreamException in project netty by netty.
the class Http2FrameCodecTest method streamErrorShouldFireExceptionForInbound.
@Test
public void streamErrorShouldFireExceptionForInbound() throws Exception {
frameInboundWriter.writeInboundHeaders(3, request, 31, false);
Http2Stream stream = frameCodec.connection().stream(3);
assertNotNull(stream);
StreamException streamEx = new StreamException(3, Http2Error.INTERNAL_ERROR, "foo");
channel.pipeline().fireExceptionCaught(streamEx);
Http2FrameStreamEvent event = inboundHandler.readInboundMessageOrUserEvent();
assertEquals(Http2FrameStreamEvent.Type.State, event.type());
assertEquals(State.OPEN, event.stream().state());
Http2HeadersFrame headersFrame = inboundHandler.readInboundMessageOrUserEvent();
assertNotNull(headersFrame);
Http2FrameStreamException e = assertThrows(Http2FrameStreamException.class, new Executable() {
@Override
public void execute() throws Throwable {
inboundHandler.checkException();
}
});
assertEquals(streamEx, e.getCause());
assertNull(inboundHandler.readInboundMessageOrUserEvent());
}
use of io.netty.handler.codec.http2.Http2Exception.StreamException in project zuul by Netflix.
the class Http2StreamErrorHandler method exceptionCaught.
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (cause instanceof StreamException) {
StreamException streamEx = (StreamException) cause;
ctx.writeAndFlush(new DefaultHttp2ResetFrame(streamEx.error()));
} else if (cause instanceof DecoderException) {
ctx.writeAndFlush(new DefaultHttp2ResetFrame(Http2Error.PROTOCOL_ERROR));
} else {
super.exceptionCaught(ctx, cause);
}
}
Aggregations