Buggy code:
public final int opcode ; public final Message . Direction direction ; public final Message . Codec < ? > codec ; private static final Message . Type [ ] opcodeIdx ; private Type ( int opcode , Message . Direction direction , Message . Codec < ? > codec ) { } public static Message . Type fromOpcode ( int opcode , Message . Direction direction ) { } } public final Message . Type type ; protected Connection connection ; private int streamId ; private Frame sourceFrame ; protected Message ( Message . Type type ) { } public void attach ( Connection connection ) { } public Connection connection ( ) { } public Message setStreamId ( int streamId ) { } public int getStreamId ( ) { } public void setSourceFrame ( Frame sourceFrame ) { } public Frame getSourceFrame ( ) { } public static abstract class Request extends Message { protected boolean tracingRequested ; protected Request ( Message . Type type ) { } public abstract Message . Response execute ( QueryState queryState ) { } public void setTracingRequested ( ) { } public boolean isTracingRequested ( ) { } } public static abstract class Response extends Message { protected UUID tracingId ; protected Response ( Message . Type type ) { } public Message setTracingId ( UUID tracingId ) { } public UUID getTracingId ( ) { } } @ ChannelHandler . Sharable public static class ProtocolDecoder extends MessageToMessageDecoder < Frame > { public void decode ( ChannelHandlerContext ctx , Frame frame , List results ) { } } @ ChannelHandler . Sharable public static class ProtocolEncoder extends MessageToMessageEncoder < Message > { public void encode ( ChannelHandlerContext ctx , Message message , List results ) { } } @ ChannelHandler . Sharable public static class Dispatcher extends SimpleChannelInboundHandler < Message . Request > { private static class FlushItem { final ChannelHandlerContext ctx ; final Object response ; final Frame sourceFrame ; private FlushItem ( ChannelHandlerContext ctx , Object response , Frame sourceFrame ) { } } private static final class Flusher implements Runnable { final EventLoop eventLoop ; final ConcurrentLinkedQueue < Message . Dispatcher . FlushItem > queued = new ConcurrentLinkedQueue < > ( ) ; final AtomicBoolean running = new AtomicBoolean ( false ) ; final HashSet < ChannelHandlerContext > channels = new HashSet < > ( ) ; final List < Message . Dispatcher . FlushItem > flushed = new ArrayList < > ( ) ; int runsSinceFlush = 0 ; int runsWithNoWork = 0 ; private Flusher ( EventLoop eventLoop ) { } void start ( ) { } public void run ( ) { } } private static final ConcurrentMap < EventLoop , Message . Dispatcher . Flusher > flusherLookup = new ConcurrentHashMap < > ( ) ; public Dispatcher ( ) { } @ Override public void channelRead0 ( final ChannelHandlerContext ctx , final Message . Request request ) { final Message . Response response ; final ServerConnection connection ; try { assert ( request . connection ( ) ) instanceof ServerConnection ; connection = ( ( ServerConnection ) ( request . connection ( ) ) ) ; QueryState qstate = connection . validateNewMessage ( request . type , connection . getVersion ( ) , request . getStreamId ( ) ) ; Message . logger . debug ( "Received:<seq2seq4repair_space>{},<seq2seq4repair_space>v={}" , request , connection . getVersion ( ) ) ; response = request . execute ( qstate ) ; response . setStreamId ( request . getStreamId ( ) ) ; response . attach ( connection ) ; connection . applyStateTransition ( request . type , response . type ) ; } catch ( Throwable t ) { JVMStabilityInspector . inspectThrowable ( t ) ; <START_BUG> final Message . UnexpectedChannelExceptionHandler handler = new Message . UnexpectedChannelExceptionHandler ( ctx . channel ( ) , true ) ; <END_BUG> EventLoop loop = ctx . channel ( ) . eventLoop ( ) ; loop . execute ( new Runnable ( ) { @ Override public void run ( ) { ctx . write ( ErrorMessage . fromException ( t , handler ) . setStreamId ( request . getStreamId ( ) ) , ctx . voidPromise ( ) ) ; ctx . flush ( ) ; request . getSourceFrame ( ) . release ( ) ; } } ) ; return ; } Message . logger . debug ( "Responding:<seq2seq4repair_space>{},<seq2seq4repair_space>v={}" , response , connection . getVersion ( ) ) ; EventLoop loop = ctx . channel ( ) . eventLoop ( ) ; loop . execute ( new Runnable ( ) { @ Override public void run ( ) { ctx . write ( response , ctx . voidPromise ( ) ) ; ctx . flush ( ) ; request . getSourceFrame ( ) . release ( ) ; } } ) ; } @ Override public void exceptionCaught ( final ChannelHandlerContext ctx , Throwable cause ) throws Exception { } } static final class UnexpectedChannelExceptionHandler implements Predicate < Throwable > { private final Channel channel ; private final boolean alwaysLogAtError ; UnexpectedChannelExceptionHandler ( Channel channel , boolean alwaysLogAtError ) { } @ Override public boolean apply ( Throwable exception ) { } } }

Fix:
Message . UnexpectedChannelExceptionHandler handler = new Message . UnexpectedChannelExceptionHandler ( ctx . channel ( ) , true ) ;