@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent event) throws Exception { try { ChannelBuffer message = (ChannelBuffer) event.getMessage(); handleRequest(message, event.getChannel()); } catch (Throwable e) { msgLog.error("Error handling request", e); // Attempt to reply to the client ChunkingChannelBuffer buffer = newChunkingBuffer(event.getChannel()); buffer.clear(/* failure = */ true); writeFailureResponse(e, buffer); ctx.getChannel().close(); tryToFinishOffChannel(ctx.getChannel()); throw Exceptions.launderedException(e); } }
@Override protected void writeFailureResponse(Throwable exception, ChunkingChannelBuffer buffer) { responseFailureEncountered = true; super.writeFailureResponse(exception, buffer); }