io.netty.util.IllegalReferenceCountException Java Examples

The following examples show how to use io.netty.util.IllegalReferenceCountException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testReadBytesAfterRelease3() {
    ByteBuf buffer = buffer(8);
    try {
        releasedBuffer().readBytes(buffer);
    } finally {
        buffer.release();
    }
}
 
Example #2
Source File: RedisDecoderTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void shouldErrorOnReleasecontentOfArrayChildReferenceCounted() throws Exception {
    ByteBuf buf = Unpooled.buffer();
    buf.writeBytes(byteBufOf("*2\r\n"));
    buf.writeBytes(byteBufOf("$3\r\nFoo\r\n$3\r\nBar\r\n"));
    assertTrue(channel.writeInbound(buf));

    ArrayRedisMessage msg = channel.readInbound();

    List<RedisMessage> children = msg.children();
    ByteBuf childBuf = ((FullBulkStringRedisMessage) children.get(0)).content();
    ReferenceCountUtil.release(msg);
    ReferenceCountUtil.release(childBuf);
}
 
Example #3
Source File: RedisDecoderTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void shouldErrorOnReleaseArrayChildReferenceCounted() throws Exception {
    ByteBuf buf = Unpooled.buffer();
    buf.writeBytes(byteBufOf("*2\r\n"));
    buf.writeBytes(byteBufOf("*3\r\n:1\r\n:2\r\n:3\r\n"));
    buf.writeBytes(byteBufOf("$3\r\nFoo\r\n"));
    assertTrue(channel.writeInbound(buf));

    ArrayRedisMessage msg = channel.readInbound();

    List<RedisMessage> children = msg.children();
    ReferenceCountUtil.release(msg);
    ReferenceCountUtil.release(children.get(1));
}
 
Example #4
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test
public void testArrayAfterRelease() {
    ByteBuf buf = releasedBuffer();
    if (buf.hasArray()) {
        try {
            buf.array();
            fail();
        } catch (IllegalReferenceCountException e) {
            // expected
        }
    }
}
 
Example #5
Source File: DefaultSpdyDataFrame.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf content() {
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
 
Example #6
Source File: DefaultHttp2DataFrame.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf content() {
    if (content.refCnt() <= 0) {
        throw new IllegalReferenceCountException(content.refCnt());
    }
    return content;
}
 
Example #7
Source File: RequestQueueTest.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
    int last = getAndDecrement();
    if (last <= 0) {
        throw new IllegalReferenceCountException(last);
    }
}
 
Example #8
Source File: RedisDecoderTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void shouldErrorOnDoubleReleaseArrayReferenceCounted() throws Exception {
    ByteBuf buf = Unpooled.buffer();
    buf.writeBytes(byteBufOf("*2\r\n"));
    buf.writeBytes(byteBufOf("*3\r\n:1\r\n:2\r\n:3\r\n"));
    buf.writeBytes(byteBufOf("*2\r\n+Foo\r\n-Bar\r\n"));
    assertTrue(channel.writeInbound(buf));

    ArrayRedisMessage msg = channel.readInbound();

    ReferenceCountUtil.release(msg);
    ReferenceCountUtil.release(msg);
}
 
Example #9
Source File: MqttPublishMessage.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf content() {
    final ByteBuf data = (ByteBuf) super.payload();
    if (data.refCnt() <= 0) {
        throw new IllegalReferenceCountException(data.refCnt());
    }
    return data;
}
 
Example #10
Source File: PemValue.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf content() {
    int count = refCnt();
    if (count <= 0) {
        throw new IllegalReferenceCountException(count);
    }

    return content;
}
 
Example #11
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease3() {
    ByteBuf buffer = buffer();
    try {
        releasedBuffer().setBytes(0, buffer, 0, 1);
    } finally {
        buffer.release();
    }
}
 
Example #12
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testWriteBytesAfterRelease() {
    ByteBuf buffer = buffer(8);
    try {
        releasedBuffer().writeBytes(buffer);
    } finally {
        buffer.release();
    }
}
 
Example #13
Source File: AbstractReferenceCountedByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testRetainOverflow() {
    AbstractReferenceCountedByteBuf referenceCounted = newReferenceCounted();
    referenceCounted.setRefCnt(Integer.MAX_VALUE);
    assertEquals(Integer.MAX_VALUE, referenceCounted.refCnt());
    referenceCounted.retain();
}
 
Example #14
Source File: AbstractReferenceCountedByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testRetainResurrect() {
    AbstractReferenceCountedByteBuf referenceCounted = newReferenceCounted();
    assertTrue(referenceCounted.release());
    assertEquals(0, referenceCounted.refCnt());
    referenceCounted.retain();
}
 
Example #15
Source File: AbstractReferenceCountedByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testRetainResurrect2() {
    AbstractReferenceCountedByteBuf referenceCounted = newReferenceCounted();
    assertTrue(referenceCounted.release());
    assertEquals(0, referenceCounted.refCnt());
    referenceCounted.retain(2);
}
 
Example #16
Source File: PemX509Certificate.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
public ByteBuf content() {
    int count = refCnt();
    if (count <= 0) {
        throw new IllegalReferenceCountException(count);
    }

    return content;
}
 
Example #17
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testWriteBytesAfterRelease3() {
    ByteBuf buffer = buffer(8);
    try {
        releasedBuffer().writeBytes(buffer, 0, 1);
    } finally {
        buffer.release();
    }
}
 
Example #18
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease2() {
    ByteBuf buffer = buffer();
    try {
        releasedBuffer().getBytes(0, buffer, 1);
    } finally {
        buffer.release();
    }
}
 
Example #19
Source File: MockParameter.java    From r2dbc-mysql with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
    int refCnt;

    do {
        refCnt = get();

        if (refCnt <= 0) {
            throw new IllegalReferenceCountException(refCnt);
        }
    } while (!compareAndSet(refCnt, refCnt - 1));
}
 
Example #20
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testSetBooleanAfterRelease() {
    releasedBuffer().setBoolean(0, true);
}
 
Example #21
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease5() {
    releasedBuffer().getBytes(0, new byte[8], 0, 1);
}
 
Example #22
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testSetBytesAfterRelease5() {
    releasedBuffer().setBytes(0, new byte[8], 0, 1);
}
 
Example #23
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetDoubleLEAfterRelease() {
    releasedBuffer().getDoubleLE(0);
}
 
Example #24
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetDoubleAfterRelease() {
    releasedBuffer().getDouble(0);
}
 
Example #25
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testWriteUsAsciiCharSequenceAfterRelease() {
    testWriteCharSequenceAfterRelease0(CharsetUtil.US_ASCII);
}
 
Example #26
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease8() throws IOException {
    releasedBuffer().getBytes(0, new DevNullGatheringByteChannel(), 1);
}
 
Example #27
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testSetByteAfterRelease() {
    releasedBuffer().setByte(0, 1);
}
 
Example #28
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testWriteZeroAfterRelease() throws IOException {
    releasedBuffer().writeZero(1);
}
 
Example #29
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testWriteFloatLEAfterRelease() {
    releasedBuffer().writeFloatLE(1);
}
 
Example #30
Source File: AbstractByteBufTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Test(expected = IllegalReferenceCountException.class)
public void testGetBytesAfterRelease6() {
    releasedBuffer().getBytes(0, ByteBuffer.allocate(8));
}