Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.duplicate()


            public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
                if (done) {
                    return null;
                }
                done = true;
                return buffer.duplicate().retain();
            }

            @Override
            public long length() {
                return -1;
View Full Code Here


        channel.config().setWriteBufferLowWaterMark(1);
        channel.config().setWriteBufferHighWaterMark(3);

        ByteBuf[] buffers = new ByteBuf[count];
        for (int i = 0; i < buffers.length; i++) {
            buffers[i] = buffer.duplicate().retain();
        }
        Assert.assertTrue(channel.writeOutbound(buffers));
        Assert.assertTrue(channel.finish());
        channel.closeFuture().syncUninterruptibly();
View Full Code Here

    private static void assertWriteFails(ChannelHandler handler, int count) {
        final ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.US_ASCII);
        final EmbeddedChannel channel = new EmbeddedChannel(handler);
        ByteBuf[] buffers = new ByteBuf[count];
        for (int i = 0; i < buffers.length; i++) {
            buffers[i] = buffer.duplicate().retain();
        }
        try {
            Assert.assertFalse(channel.writeOutbound(buffers));
            Assert.fail();
        } catch (Exception e) {
View Full Code Here

        MemoryFileUpload upload = new MemoryFileUpload(getName(), getFilename(), getContentType(),
                getContentTransferEncoding(), getCharset(), size);
        ByteBuf buf = content();
        if (buf != null) {
            try {
                upload.setContent(buf.duplicate());
                return upload;
            } catch (IOException e) {
                throw new ChannelException(e);
            }
        }
View Full Code Here

        DiskFileUpload upload = new DiskFileUpload(getName(),
                getFilename(), getContentType(), getContentTransferEncoding(), getCharset(), size);
        ByteBuf buf = content();
        if (buf != null) {
            try {
                upload.setContent(buf.duplicate());
            } catch (IOException e) {
                throw new ChannelException(e);
            }
        }
        return upload;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.