/** * Called once an user event hit the end of the {@link ChannelPipeline} without been handled by the user * in {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}. This method is responsible * to call {@link ReferenceCountUtil#release(Object)} on the given event at some point. */ protected void onUnhandledInboundUserEventTriggered(Object evt) { // This may not be a configuration error and so don't log anything. // The event may be superfluous for the current pipeline configuration. ReferenceCountUtil.release(evt); }
@Override public boolean release(int decrement) { return ReferenceCountUtil.release(message, decrement); }
@Override public boolean release() { return ReferenceCountUtil.release(message); }
/** * Called once an user event hit the end of the {@link ChannelPipeline} without been handled by the user * in {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)}. This method is responsible * to call {@link ReferenceCountUtil#release(Object)} on the given event at some point. */ protected void onUnhandledInboundUserEventTriggered(Object evt) { // This may not be a configuration error and so don't log anything. // The event may be superfluous for the current pipeline configuration. ReferenceCountUtil.release(evt); }
@Override void destroy() { for (Object material: materialMap.values()) { ReferenceCountUtil.release(material); } materialMap.clear(); } }
private void invokeHandleOversizedMessage(ChannelHandlerContext ctx, S oversized) throws Exception { handlingOversizedMessage = true; currentMessage = null; try { handleOversizedMessage(ctx, oversized); } finally { // Release the message in case it is a full one. ReferenceCountUtil.release(oversized); } }
private static boolean releaseAll(Queue<Object> queue) { if (isNotEmpty(queue)) { for (;;) { Object msg = queue.poll(); if (msg == null) { break; } ReferenceCountUtil.release(msg); } return true; } return false; }
/** * Called once a {@link Throwable} hit the end of the {@link ChannelPipeline} without been handled by the user * in {@link ChannelHandler#exceptionCaught(ChannelHandlerContext, Throwable)}. */ protected void onUnhandledInboundException(Throwable cause) { try { logger.warn( "An exceptionCaught() event was fired, and it reached at the tail of the pipeline. " + "It usually means the last handler in the pipeline did not handle the exception.", cause); } finally { ReferenceCountUtil.release(cause); } }
/** * Try to call {@link ReferenceCounted#release()} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. * Unlike {@link #release(Object)} this method catches an exception raised by {@link ReferenceCounted#release()} * and logs it, rather than rethrowing it to the caller. It is usually recommended to use {@link #release(Object)} * instead, unless you absolutely need to swallow an exception. */ public static void safeRelease(Object msg) { try { release(msg); } catch (Throwable t) { logger.warn("Failed to release a message: {}", msg, t); } }
/** * Called once a message hit the end of the {@link ChannelPipeline} without been handled by the user * in {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)}. This method is responsible * to call {@link ReferenceCountUtil#release(Object)} on the given msg at some point. */ protected void onUnhandledInboundMessage(Object msg) { try { logger.debug( "Discarded inbound message {} that reached at the tail of the pipeline. " + "Please check your pipeline configuration.", msg); } finally { ReferenceCountUtil.release(msg); } }
@Override public synchronized void handleMessage(Object msg) { if (msg instanceof HttpContent) { if (msg instanceof LastHttpContent) { stream.endResponse((LastHttpContent) msg); } ReferenceCountUtil.release(msg); return; } super.handleMessage(msg); }
@Override public synchronized void handleMessage(Object msg) { if (msg instanceof HttpContent) { ReferenceCountUtil.release(msg); return; } super.handleMessage(msg); } };
private void invokeHandleOversizedMessage(ChannelHandlerContext ctx, S oversized) throws Exception { handlingOversizedMessage = true; currentMessage = null; try { handleOversizedMessage(ctx, oversized); } finally { // Release the message in case it is a full one. ReferenceCountUtil.release(oversized); } }
/** * Fails the underlying {@link Promise} with the given cause and recycle this instance. */ public boolean failAndRecycle(Throwable cause) { ReferenceCountUtil.release(msg); if (promise != null) { promise.setFailure(cause); } return recycle(); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { boolean release = true; try { if (acceptInboundMessage(msg)) { @SuppressWarnings("unchecked") I imsg = (I) msg; channelRead0(ctx, imsg); } else { release = false; ctx.fireChannelRead(msg); } } finally { if (autoRelease && release) { ReferenceCountUtil.release(msg); } } }
private static boolean safeExecute(EventExecutor executor, Runnable runnable, ChannelPromise promise, Object msg) { try { executor.execute(runnable); return true; } catch (Throwable cause) { try { promise.setFailure(cause); } finally { if (msg != null) { ReferenceCountUtil.release(msg); } } return false; } }
private void releaseInboundBuffers() { assert eventLoop() == null || eventLoop().inEventLoop(); readInProgress = false; Queue<Object> inboundBuffer = this.inboundBuffer; Object msg; while ((msg = inboundBuffer.poll()) != null) { ReferenceCountUtil.release(msg); } }
/** * Try to call {@link ReferenceCounted#release(int)} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. * Unlike {@link #release(Object)} this method catches an exception raised by {@link ReferenceCounted#release(int)} * and logs it, rather than rethrowing it to the caller. It is usually recommended to use * {@link #release(Object, int)} instead, unless you absolutely need to swallow an exception. */ public static void safeRelease(Object msg, int decrement) { try { release(msg, decrement); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("Failed to release a message: {} (decrement: {})", msg, decrement, t); } } }
/** * Fails the underlying {@link Promise} with the given cause and recycle this instance. */ public boolean failAndRecycle(Throwable cause) { ReferenceCountUtil.release(msg); if (promise != null) { promise.setFailure(cause); } return recycle(); }
private void releaseInboundBuffers() { assert eventLoop() == null || eventLoop().inEventLoop(); readInProgress = false; Queue<Object> inboundBuffer = this.inboundBuffer; Object msg; while ((msg = inboundBuffer.poll()) != null) { ReferenceCountUtil.release(msg); } }