@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (!queue.isEmpty()) { queue.releaseAndFailAll(new ConnectionClosedException("Connection closed")); } ctx.close(promise); } }
@Override public void run() { ctx.close(promise); } }, 10, TimeUnit.SECONDS); // FIXME: Magic number
@Override public void run() { ctx.close(promise); } }, timeout, unit);
@Override public void operationComplete(ChannelFuture f) throws Exception { ctx.close(promise); } });
/** * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. * * Sub-classes may override this method to change behavior. */ @Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { ctx.close(promise); }
@Override public void operationComplete(ChannelFuture f) throws Exception { ctx.close(promise); } });
@Override public void run() { ctx.close(promise); } }, 10, TimeUnit.SECONDS); // FIXME: Magic number
/** * Calls {@link ChannelHandlerContext#close(ChannelPromise)} to forward * to the next {@link ChannelOutboundHandler} in the {@link ChannelPipeline}. * * Sub-classes may override this method to change behavior. */ @Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { ctx.close(promise); }
@Override public void operationComplete(ChannelFuture f) throws Exception { ctx.close(promise); } });
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause instanceof TooLongFrameException) { ctx.close(); } else { super.exceptionCaught(ctx, cause); } } }
@Override protected void decode(ChannelHandlerContext ctx, WebSocketFrame frame, List<Object> out) throws Exception { if (handleCloseFrames && frame instanceof CloseWebSocketFrame) { ctx.close(); return; } super.decode(ctx, frame, out); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { logger.warn("{} Failed to select the application-level protocol:", ctx.channel(), cause); ctx.close(); } }
/** * Invoked on failed initial SSL/TLS handshake. */ protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause) throws Exception { logger.warn("{} TLS handshake failed:", ctx.channel(), cause); ctx.close(); }
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { logger.debug("Failed to send a 413 Request Entity Too Large.", future.cause()); } ctx.close(); } });
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { logger.debug("Failed to send a 413 Request Entity Too Large.", future.cause()); ctx.close(); } } });
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { if (logger.isEnabled(internalLevel)) { logger.log(internalLevel, format(ctx, "CLOSE")); } ctx.close(promise); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (cause instanceof WebSocketHandshakeException) { FullHttpResponse response = new DefaultFullHttpResponse( HTTP_1_1, HttpResponseStatus.BAD_REQUEST, Unpooled.wrappedBuffer(cause.getMessage().getBytes())); ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { ctx.fireExceptionCaught(cause); ctx.close(); } }