@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBufPair) { ByteBufPair b = (ByteBufPair) msg; // Some handlers in the pipeline will modify the bytebufs passed in to them (i.e. SslHandler). // For these handlers, we need to pass a copy of the buffers as the source buffers may be cached // for multiple requests. try { ctx.write(b.getFirst().copy(), ctx.voidPromise()); ctx.write(b.getSecond().copy(), promise); } finally { ReferenceCountUtil.safeRelease(b); } } else { ctx.write(msg, promise); } } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBufPair) { ByteBufPair b = (ByteBufPair) msg; // Write each buffer individually on the socket. The retain() here is needed to preserve the fact that // ByteBuf are automatically released after a write. If the ByteBufPair ref count is increased and it // gets written multiple times, the individual buffers refcount should be reflected as well. try { ctx.write(b.getFirst().retainedDuplicate(), ctx.voidPromise()); ctx.write(b.getSecond().retainedDuplicate(), promise); } finally { ReferenceCountUtil.safeRelease(b); } } else { ctx.write(msg, promise); } } }
ByteBufPair msg = op.cmd; if (msg != null) { ByteBuf headerFrame = msg.getFirst(); headerFrame.markReaderIndex(); try {
ByteBuf headerFrame = msg.getFirst(); headerFrame.markReaderIndex(); try {
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBufPair) { ByteBufPair b = (ByteBufPair) msg; // Some handlers in the pipeline will modify the bytebufs passed in to them (i.e. SslHandler). // For these handlers, we need to pass a copy of the buffers as the source buffers may be cached // for multiple requests. try { ctx.write(b.getFirst().copy(), ctx.voidPromise()); ctx.write(b.getSecond().copy(), promise); } finally { ReferenceCountUtil.safeRelease(b); } } else { ctx.write(msg, promise); } } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (msg instanceof ByteBufPair) { ByteBufPair b = (ByteBufPair) msg; // Write each buffer individually on the socket. The retain() here is needed to preserve the fact that // ByteBuf are automatically released after a write. If the ByteBufPair ref count is increased and it // gets written multiple times, the individual buffers refcount should be reflected as well. try { ctx.write(b.getFirst().retainedDuplicate(), ctx.voidPromise()); ctx.write(b.getSecond().retainedDuplicate(), promise); } finally { ReferenceCountUtil.safeRelease(b); } } else { ctx.write(msg, promise); } } }
ByteBufPair msg = op.cmd; if (msg != null) { ByteBuf headerFrame = msg.getFirst(); headerFrame.markReaderIndex(); try {
ByteBuf headerFrame = msg.getFirst(); headerFrame.markReaderIndex(); try {