@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Throwable cause = e.getCause(); if (cause instanceof IOException) { if (cause instanceof ClosedChannelException) { synchronized (ignoreClosedChannelExceptionLock) { if (ignoreClosedChannelException > 0) { ignoreClosedChannelException --; if (logger.isDebugEnabled()) { logger.debug( "Swallowing an exception raised while " + "writing non-app data", cause); } return; } } } else { if (ignoreException(cause)) { return; } } } ctx.sendUpstream(e); }