Java 类io.netty.util.IllegalReferenceCountException 实例源码

项目:sailfish    文件:ReferenceCountedServerExchangeChannelGroup.java   
private boolean release0(int decrement) {
    for (;;) {
        int refCnt = this.refCnt;
        if (refCnt < decrement) {
            throw new IllegalReferenceCountException(refCnt, -decrement);
        }

        if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
            if (refCnt == decrement) {
                deallocate();
                return true;
            }
            return false;
        }
    }
}
项目:netty4.0.27Learn    文件:AbstractReferenceCountedByteBuf.java   
@Override
public final boolean release(int decrement) {
    if (decrement <= 0) {
        throw new IllegalArgumentException("decrement: " + decrement + " (expected: > 0)");
    }

    for (;;) {
        int refCnt = this.refCnt;
        if (refCnt < decrement) {
            throw new IllegalReferenceCountException(refCnt, -decrement);
        }

        if (refCntUpdater.compareAndSet(this, refCnt, refCnt - decrement)) {
            if (refCnt == decrement) {
                deallocate();
                return true;
            }
            return false;
        }
    }
}
项目:j1st-mqtt    文件:MqttPublishMessage.java   
@Override
public ByteBuf content() {
    final ByteBuf data = (ByteBuf) super.payload();
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
项目:DovakinMQ    文件:MqttPublishMessage.java   
@Override
public ByteBuf content() {
    final ByteBuf data = (ByteBuf) super.payload();
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
项目:HeliosStreams    文件:ConnectionManager.java   
/**
 * {@inheritDoc}
 * @see io.netty.channel.ChannelInboundHandlerAdapter#exceptionCaught(io.netty.channel.ChannelHandlerContext, java.lang.Throwable)
 */
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
    final Channel chan = ctx.channel();
    if (cause instanceof ClosedChannelException) {
        exceptions_closed.inc();
        log.warn("Attempt to write to closed channel " + chan);
        return;
    } else if(cause instanceof IllegalReferenceCountException) {
        log.warn("BadRefCount: [{}]", cause.getMessage());
    } else if (cause instanceof IOException) {
        final String message = cause.getMessage();
        if ("Connection reset by peer".equals(message)) {
            exceptions_reset.inc();
            return;
        } else if ("Connection timed out".equals(message)) {
            exceptions_timeout.inc();
            // Do nothing.  A client disconnecting isn't really our problem.  Oh,
            // and I'm not kidding you, there's no better way to detect ECONNRESET
            // in Java.  Like, people have been bitching about errno for years,
            // and Java managed to do something *far* worse.  That's quite a feat.
            return;
        }
    }
    // FIXME: not sure what the netty 4 is for this
    //if (cause instanceof CodecEmbedderException) {
    //  // payload was not compressed as it was announced to be
    //  log.warn("Http codec error : " + cause.getMessage());
    //  e.getChannel().close();
    //  return;
    //}
    exceptions_unknown.inc();
    log.error("Unexpected exception from downstream for " + chan, cause);
    chan.close();
}
项目:HeliosStreams    文件:ConnectionManager.java   
/**
 * {@inheritDoc}
 * @see io.netty.channel.ChannelInboundHandlerAdapter#exceptionCaught(io.netty.channel.ChannelHandlerContext, java.lang.Throwable)
 */
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
    final Channel chan = ctx.channel();
    if (cause instanceof ClosedChannelException) {
        exceptions_closed.inc();
        log.warn("Attempt to write to closed channel " + chan);
        return;
    } else if(cause instanceof IllegalReferenceCountException) {
        log.warn("BadRefCount: [{}]", cause.getMessage());
    } else if (cause instanceof IOException) {
        final String message = cause.getMessage();
        if ("Connection reset by peer".equals(message)) {
            exceptions_reset.inc();
            return;
        } else if ("Connection timed out".equals(message)) {
            exceptions_timeout.inc();
            // Do nothing.  A client disconnecting isn't really our problem.  Oh,
            // and I'm not kidding you, there's no better way to detect ECONNRESET
            // in Java.  Like, people have been bitching about errno for years,
            // and Java managed to do something *far* worse.  That's quite a feat.
            return;
        }
    }
    // FIXME: not sure what the netty 4 is for this
    //if (cause instanceof CodecEmbedderException) {
    //  // payload was not compressed as it was announced to be
    //  log.warn("Http codec error : " + cause.getMessage());
    //  e.getChannel().close();
    //  return;
    //}
    exceptions_unknown.inc();
    log.error("Unexpected exception from downstream for " + chan, cause);
    chan.close();
}
项目:netty4.0.27Learn    文件:DefaultByteBufHolder.java   
@Override
public ByteBuf content() {
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test
public void testArrayAfterRelease() {
    ByteBuf buf = releasedBuffer();
    if (buf.hasArray()) {
        try {
            buf.array();
            fail();
        } catch (IllegalReferenceCountException e) {
            // expected
        }
    }
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test
public void testMemoryAddressAfterRelease() {
    ByteBuf buf = releasedBuffer();
    if (buf.hasMemoryAddress()) {
        try {
            buf.memoryAddress();
            fail();
        } catch (IllegalReferenceCountException e) {
            // expected
        }
    }
}
项目:SpudCompat    文件:SimpleNBT.java   
private void assertAccessible() {
    if (refCnt() == 0) throw new IllegalReferenceCountException(0);
}
项目:SpudCompat    文件:RawPacket.java   
private void assertValid() {
    if (refCnt() <= 0) throw new IllegalReferenceCountException("Packet deallocated");
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease7() throws IOException {
    releasedBuffer().getBytes(0, new ByteArrayOutputStream(), 1);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testReadUnsignedMediumAfterRelease() {
    releasedBuffer().readUnsignedMedium();
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testEnsureWritableAfterRelease() {
    releasedBuffer().ensureWritable(16);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease() {
    releasedBuffer().setBytes(0, releaseLater(buffer()));
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testWriteFloatAfterRelease() {
    releasedBuffer().writeFloat(1);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetUnsignedByteAfterRelease() {
    releasedBuffer().getUnsignedByte(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease4() {
    releasedBuffer().getBytes(0, new byte[8]);
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testDiscardSomeReadBytesAfterRelease() {
    releasedBuffer().discardSomeReadBytes();
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testEnsureWritableAfterRelease() {
    releasedBuffer().ensureWritable(16);
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBooleanAfterRelease() {
    releasedBuffer().getBoolean(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testReadLongAfterRelease() {
    releasedBuffer().readLong();
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetUnsignedByteAfterRelease() {
    releasedBuffer().getUnsignedByte(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testWriteByteAfterRelease() {
    releasedBuffer().writeByte(1);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetShortAfterRelease() {
    releasedBuffer().getShort(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testNioBuffersAfterRelease() {
    releasedBuffer().nioBuffers();
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testWriteBytesAfterRelease2() {
    releasedBuffer().writeBytes(releaseLater(copiedBuffer(new byte[8])), 1);
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetIntAfterRelease() {
    releasedBuffer().getInt(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testReadBytesAfterRelease3() {
    releasedBuffer().readBytes(releaseLater(buffer(8), 1));
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetLongAfterRelease() {
    releasedBuffer().getLong(0);
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetCharAfterRelease() {
    releasedBuffer().getChar(0);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testWriteBooleanAfterRelease() {
    releasedBuffer().writeBoolean(true);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testCopyAfterRelease() {
    releasedBuffer().copy();
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testWriteBytesAfterRelease() {
    releasedBuffer().writeBytes(releaseLater(buffer(8)));
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease3() {
    releasedBuffer().getBytes(0, releaseLater(buffer()), 0, 1);
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease4() {
    releasedBuffer().getBytes(0, new byte[8]);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease3() {
    releasedBuffer().setBytes(0, releaseLater(buffer()), 0, 1);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease8() throws IOException {
    releasedBuffer().setBytes(0, new TestScatteringByteChannel(), 1);
}
项目:netty.book.kor    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testCopyAfterRelease1() {
    releasedBuffer().copy();
}
项目:netty4.0.27Learn    文件:AbstractByteBufTest.java   
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease8() throws IOException {
    releasedBuffer().getBytes(0, new DevNullGatheringByteChannel(), 1);
}