@Test public void testFlush() { Lz4FrameEncoder encoder = new Lz4FrameEncoder(); EmbeddedChannel channel = new EmbeddedChannel(encoder); int size = 27; ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(size, size); buf.writerIndex(size); Assert.assertEquals(0, encoder.getBackingBuffer().readableBytes()); channel.write(buf); Assert.assertTrue(channel.outboundMessages().isEmpty()); Assert.assertEquals(size, encoder.getBackingBuffer().readableBytes()); channel.flush(); Assert.assertTrue(channel.finish()); Assert.assertTrue(channel.releaseOutbound()); Assert.assertFalse(channel.releaseInbound()); }
@Override public void flush(final ChannelHandlerContext ctx) throws Exception { if (buffer != null && buffer.isReadable()) { final ByteBuf buf = allocateBuffer(ctx, Unpooled.EMPTY_BUFFER, isPreferDirect(), false); flushBufferedData(buf); ctx.write(buf); } ctx.flush(); }
Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> { @Override public void flush(final ChannelHandlerContext ctx) throws Exception { if (buffer != null && buffer.isReadable()) { final ByteBuf buf = allocateBuffer(ctx, Unpooled.EMPTY_BUFFER, isPreferDirect(), false); flushBufferedData(buf); ctx.write(buf); } ctx.flush(); } }
Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> { @Override public void flush(final ChannelHandlerContext ctx) throws Exception { if (buffer != null && buffer.isReadable()) { final ByteBuf buf = allocateBuffer(ctx, Unpooled.EMPTY_BUFFER, isPreferDirect(), false); flushBufferedData(buf); ctx.write(buf); } ctx.flush(); } Lz4FrameEncoder();  Lz4FrameEncoder(boolean highCompressor);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize,
                           Checksum checksum, int maxEncodeSize); }
Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> { @Override public void flush(final ChannelHandlerContext ctx) throws Exception { if (buffer != null && buffer.isReadable()) { final ByteBuf buf = allocateBuffer(ctx, Unpooled.EMPTY_BUFFER, isPreferDirect(), false); flushBufferedData(buf); ctx.write(buf); } ctx.flush(); } Lz4FrameEncoder();  Lz4FrameEncoder(boolean highCompressor);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize,
                           Checksum checksum, int maxEncodeSize); @Override void flush(final ChannelHandlerContext ctx); boolean isClosed(); ChannelFuture close(); ChannelFuture close(final ChannelPromise promise); @Override void close(final ChannelHandlerContext ctx, final ChannelPromise promise); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(ChannelHandlerContext ctx); }
Lz4FrameEncoder extends MessageToByteEncoder<ByteBuf> { @Override public void flush(final ChannelHandlerContext ctx) throws Exception { if (buffer != null && buffer.isReadable()) { final ByteBuf buf = allocateBuffer(ctx, Unpooled.EMPTY_BUFFER, isPreferDirect(), false); flushBufferedData(buf); ctx.write(buf); } ctx.flush(); } Lz4FrameEncoder();  Lz4FrameEncoder(boolean highCompressor);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize, Checksum checksum);  Lz4FrameEncoder(LZ4Factory factory, boolean highCompressor, int blockSize,
                           Checksum checksum, int maxEncodeSize); @Override void flush(final ChannelHandlerContext ctx); boolean isClosed(); ChannelFuture close(); ChannelFuture close(final ChannelPromise promise); @Override void close(final ChannelHandlerContext ctx, final ChannelPromise promise); @Override void handlerAdded(ChannelHandlerContext ctx); @Override void handlerRemoved(ChannelHandlerContext ctx);  }