/** * Fail the connection, the {@code error} will be sent to the pipeline and the connection will * stop processing any further message. * * @param error the {@code Throwable} to propagate */ void fail(Throwable error) { messageHandler = NULL_HANDLER; conn.chctx.pipeline().fireExceptionCaught(error); }
@Override public void operationComplete(ChannelFuture future) { if (!future.isSuccess()) { future.channel().pipeline().fireExceptionCaught(future.cause()); } } };
@Override public void operationComplete(ChannelFuture future) { if (!future.isSuccess()) { future.channel().pipeline().fireExceptionCaught(future.cause()); } } };
private void fireException0(Throwable cause) { // Only fire the exception if the channel is open and registered // if not the pipeline is not setup and so it would hit the tail // of the pipeline. // See https://github.com/netty/netty/issues/1517 if (fireExceptionListener != null && channel.isRegistered()) { channel.pipeline().fireExceptionCaught(cause); } } }
private void fireException0(Throwable cause) { // Only fire the exception if the channel is open and registered // if not the pipeline is not setup and so it would hit the tail // of the pipeline. // See https://github.com/netty/netty/issues/1517 if (fireExceptionListener != null && channel.isRegistered()) { channel.pipeline().fireExceptionCaught(cause); } } }
@Override public void run() { try { doDeregister(); } catch (Throwable cause) { pipeline().fireExceptionCaught(cause); } } });
@Override public void run() { try { doDeregister(); } catch (Throwable cause) { pipeline().fireExceptionCaught(cause); } } });
protected void gracefulConnectionShutdown(Channel channel) { if (channel.isActive()) { LOG.debug("gracefullyWithDelay: firing graceful_shutdown event to make netty send a final go_away frame and then close connection. channel=" + channel.id().asShortText()); Http2Exception h2e = new Http2Exception(Http2Error.NO_ERROR, Http2Exception.ShutdownHint.GRACEFUL_SHUTDOWN); channel.pipeline().fireExceptionCaught(h2e); } else { LOG.debug("gracefullyWithDelay: connection already closed, so no need to send final go_away frame. channel=" + channel.id().asShortText()); } }
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, EpollRecvByteAllocatorHandle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { shutdownInput(false); } }
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
private void handleReadException(ChannelPipeline pipeline, ByteBuf byteBuf, Throwable cause, boolean close, RecvByteBufAllocator.Handle allocHandle) { if (byteBuf != null) { if (byteBuf.isReadable()) { readPending = false; pipeline.fireChannelRead(byteBuf); } else { byteBuf.release(); } } allocHandle.readComplete(); pipeline.fireChannelReadComplete(); pipeline.fireExceptionCaught(cause); if (close || cause instanceof IOException) { closeOnRead(pipeline); } }
/** * Clear the {@link Native#EPOLLRDHUP} flag from EPOLL, and close on failure. */ private void clearEpollRdHup() { try { clearFlag(Native.EPOLLRDHUP); } catch (IOException e) { pipeline().fireExceptionCaught(e); close(voidPromise()); } }
protected void gracefulConnectionShutdown(Channel channel) { if (channel.isActive()) { LOG.debug("gracefullyWithDelay: firing graceful_shutdown event to make netty send a final go_away frame and then close connection. channel=" + channel.id().asShortText()); Http2Exception h2e = new Http2Exception(Http2Error.NO_ERROR, Http2Exception.ShutdownHint.GRACEFUL_SHUTDOWN); channel.pipeline().fireExceptionCaught(h2e); } else { LOG.debug("gracefullyWithDelay: connection already closed, so no need to send final go_away frame. channel=" + channel.id().asShortText()); } }
@Test public void shouldNotPropagateExceptionCaught() throws Exception { ChannelInboundHandler next = mock( ChannelInboundHandler.class ); BoltConnection connection = mock( BoltConnection.class ); channel = new EmbeddedChannel( new HouseKeeper( connection, NullLog.getInstance() ), next ); channel.pipeline().fireExceptionCaught( new RuntimeException( "some exception" ) ); verify( next, never() ).exceptionCaught( any(), any() ); }
protected final void clearEpollIn0() { assert eventLoop().inEventLoop(); try { readPending = false; clearFlag(Native.EPOLLIN); } catch (IOException e) { // When this happens there is something completely wrong with either the filedescriptor or epoll, // so fire the exception through the pipeline and close the Channel. pipeline().fireExceptionCaught(e); unsafe().close(unsafe().voidPromise()); } }
protected final void clearReadFilter0() { assert eventLoop().inEventLoop(); try { readPending = false; readFilter(false); } catch (IOException e) { // When this happens there is something completely wrong with either the filedescriptor or epoll, // so fire the exception through the pipeline and close the Channel. pipeline().fireExceptionCaught(e); unsafe().close(unsafe().voidPromise()); } }
@Test public void shouldStopConnectionOnExceptionCaught() { BoltConnection connection = mock( BoltConnection.class ); channel = new EmbeddedChannel( new HouseKeeper( connection, NullLog.getInstance() ) ); channel.pipeline().fireExceptionCaught( new RuntimeException( "some exception" ) ); verify( connection ).stop(); }
@Test public void shouldLogExceptionOnExceptionCaught() { AssertableLogProvider logProvider = new AssertableLogProvider(); BoltConnection connection = mock( BoltConnection.class ); channel = new EmbeddedChannel( new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) ) ); RuntimeException exception = new RuntimeException( "some exception" ); channel.pipeline().fireExceptionCaught( exception ); verify( connection ).stop(); logProvider.assertExactly( inLog( HouseKeeper.class ).error( startsWith( "Fatal error occurred when handling a client connection" ), equalTo( exception ) ) ); }