Package io.netty.buffer

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


    @Override
    public TransferBuffer release() {
      try {
        ByteBuf byteBuf = this.queue.take();
        if (byteBuf.refCnt() > 0) {
          ReferenceCountUtil.release(byteBuf);
        }
      } catch (Exception e) {
        FSDelegation.this.log.warn(e.toString());
        Trace.trace(FSDelegation.this.log, e);
View Full Code Here


        DegelationTransferBuilder.this.log.error(e);
        Trace.trace(DegelationTransferBuilder.this.log, e);
        throw new RuntimeException(e);
      } finally {
        this.lock.unlock();
        if (buf.refCnt() > 0) {
          ReferenceCountUtil.release(buf);
        }
      }
    }
View Full Code Here

     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf input = (ByteBuf) msg;
        try {
            if (!input.isReadable() || input.refCnt() == 0) {
                return;
            }

            if (buffer == null) {
                logger.warn("CommandHandler is closed, incoming response will be discarded.");
View Full Code Here

        @Override
        protected void completed0(T result, AioSocketChannel channel) {
            channel.writeInProgress = false;

            ByteBuf buf = channel.unsafe().directOutboundContext().outboundByteBuffer();
            if (buf.refCnt() == 0) {
                return;
            }

            buf.resumeIntermediaryDeallocations();
View Full Code Here

    @Test
    public void testByteBufRelease() throws Exception {
        UnicastContentSubject<ByteBuf> subject = UnicastContentSubject.createWithoutNoSubscriptionTimeout();
        ByteBuf buffer = Unpooled.buffer();
        Assert.assertEquals("Created byte buffer not retained.", 1, buffer.refCnt());
        subject.onNext(buffer);
        subject.onCompleted();
        final AtomicInteger byteBufRefCnt = new AtomicInteger(-1);

        ByteBuf last = subject.doOnNext(new Action1<ByteBuf>() {
View Full Code Here

            }
        }).toBlocking().last();

        Assert.assertEquals("Unexpected ByteBuf ref count when received.", 2, byteBufRefCnt.get());
        Assert.assertSame("Unexpected byte buffer received.", buffer, last);
        Assert.assertEquals("Byte buffer not released.", 0, last.refCnt());
    }

    private static class OnUnsubscribeAction implements Action0 {

        private volatile boolean called;
View Full Code Here

     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf input = (ByteBuf) msg;
        try {
            if (!input.isReadable() || input.refCnt() == 0) {
                return;
            }

            if (buffer == null) {
                logger.warn("CommandHandler is closed, incoming response will be discarded.");
View Full Code Here

     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf input = (ByteBuf) msg;
        try {
            if (!input.isReadable() || input.refCnt() == 0) {
                return;
            }

            if (buffer == null) {
                logger.warn("CommandHandler is closed, incoming response will be discarded.");
View Full Code Here

     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf input = (ByteBuf) msg;
        try {
            if (!input.isReadable() || input.refCnt() == 0) {
                return;
            }

            if (buffer == null) {
                logger.warn("CommandHandler is closed, incoming response will be discarded.");
View Full Code Here

        }
        if (msg instanceof WebsocketErrorMessage) {
            handle((WebsocketErrorMessage) msg, ctx.channel(), out);
        }

        if (out.refCnt() > 0) {
            log.warn("Buf for message: {} has not been deallocated, refCnt: {}! Forcing release it!", msg, out.refCnt());
            out.release();
        }
    }
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.