Search in sources :

Example 1 with IllegalReferenceCountException

use of org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException in project drill by axbaretto.

the class BoundsCheckingTest method testLengthCheck.

@Test
public void testLengthCheck() {
    try {
        BoundsChecking.lengthCheck(null, 0, 0);
        fail("expecting NullPointerException");
    } catch (NullPointerException e) {
        logger.debug("", e);
    }
    try (DrillBuf buffer = allocator.buffer(1)) {
        try {
            BoundsChecking.lengthCheck(buffer, 0, -1);
            fail("expecting IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            logger.debug("", e);
        }
        BoundsChecking.lengthCheck(buffer, 0, 0);
        BoundsChecking.lengthCheck(buffer, 0, 1);
        try {
            BoundsChecking.lengthCheck(buffer, 0, 2);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
        try {
            BoundsChecking.lengthCheck(buffer, 2, 0);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
        try {
            BoundsChecking.lengthCheck(buffer, -1, 0);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
    }
    DrillBuf buffer = allocator.buffer(1);
    buffer.release();
    try {
        BoundsChecking.lengthCheck(buffer, 0, 0);
        fail("expecting IllegalReferenceCountException");
    } catch (IllegalReferenceCountException e) {
        logger.debug("", e);
    }
}
Also used : IllegalReferenceCountException(io.netty.util.IllegalReferenceCountException) DrillBuf(io.netty.buffer.DrillBuf) Test(org.junit.Test)

Example 2 with IllegalReferenceCountException

use of org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException in project drill by apache.

the class BoundsCheckingTest method testLengthCheck.

@Test
public void testLengthCheck() {
    assertTrue(BoundsChecking.BOUNDS_CHECKING_ENABLED);
    try {
        BoundsChecking.lengthCheck(null, 0, 0);
        fail("expecting NullPointerException");
    } catch (NullPointerException e) {
        logger.debug("", e);
    }
    try (DrillBuf buffer = allocator.buffer(1)) {
        try {
            BoundsChecking.lengthCheck(buffer, 0, -1);
            fail("expecting IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            logger.debug("", e);
        }
        BoundsChecking.lengthCheck(buffer, 0, 0);
        BoundsChecking.lengthCheck(buffer, 0, 1);
        try {
            BoundsChecking.lengthCheck(buffer, 0, 2);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
        try {
            BoundsChecking.lengthCheck(buffer, 2, 0);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
        try {
            BoundsChecking.lengthCheck(buffer, -1, 0);
            fail("expecting IndexOutOfBoundsException");
        } catch (IndexOutOfBoundsException e) {
            logger.debug("", e);
        }
    }
    DrillBuf buffer = allocator.buffer(1);
    buffer.release();
    try {
        BoundsChecking.lengthCheck(buffer, 0, 0);
        fail("expecting IllegalReferenceCountException");
    } catch (IllegalReferenceCountException e) {
        logger.debug("", e);
    }
}
Also used : IllegalReferenceCountException(io.netty.util.IllegalReferenceCountException) DrillBuf(io.netty.buffer.DrillBuf) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Example 3 with IllegalReferenceCountException

use of org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException in project flink by apache.

the class AbstractByteBufTest method assertSliceFailAfterRelease.

private static void assertSliceFailAfterRelease(ByteBuf... bufs) {
    for (ByteBuf buf : bufs) {
        if (buf.refCnt() > 0) {
            buf.release();
        }
    }
    for (ByteBuf buf : bufs) {
        try {
            assertEquals(0, buf.refCnt());
            buf.slice();
            fail();
        } catch (IllegalReferenceCountException ignored) {
        // as expected
        }
    }
}
Also used : IllegalReferenceCountException(org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException) ByteBuf(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)

Example 4 with IllegalReferenceCountException

use of org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException in project flink by apache.

the class AbstractByteBufTest method assertRetainedSliceFailAfterRelease.

private static void assertRetainedSliceFailAfterRelease(ByteBuf... bufs) {
    for (ByteBuf buf : bufs) {
        if (buf.refCnt() > 0) {
            buf.release();
        }
    }
    for (ByteBuf buf : bufs) {
        try {
            assertEquals(0, buf.refCnt());
            buf.retainedSlice();
            fail();
        } catch (IllegalReferenceCountException ignored) {
        // as expected
        }
    }
}
Also used : IllegalReferenceCountException(org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException) ByteBuf(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)

Example 5 with IllegalReferenceCountException

use of org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException in project flink by apache.

the class AbstractByteBufTest method assertRetainedDuplicateFailAfterRelease.

private static void assertRetainedDuplicateFailAfterRelease(ByteBuf... bufs) {
    for (ByteBuf buf : bufs) {
        if (buf.refCnt() > 0) {
            buf.release();
        }
    }
    for (ByteBuf buf : bufs) {
        try {
            assertEquals(0, buf.refCnt());
            buf.retainedDuplicate();
            fail();
        } catch (IllegalReferenceCountException ignored) {
        // as expected
        }
    }
}
Also used : IllegalReferenceCountException(org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException) ByteBuf(org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf)6 IllegalReferenceCountException (org.apache.flink.shaded.netty4.io.netty.util.IllegalReferenceCountException)6 IllegalReferenceCountException (io.netty.util.IllegalReferenceCountException)5 Test (org.junit.Test)5 DrillBuf (io.netty.buffer.DrillBuf)2 Channel (io.netty.channel.Channel)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 LocalChannel (io.netty.channel.local.LocalChannel)1 LocalServerChannel (io.netty.channel.local.LocalServerChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)1 CodecException (io.netty.handler.codec.CodecException)1 ClientConfiguration (org.apache.bookkeeper.conf.ClientConfiguration)1 BaseTest (org.apache.drill.test.BaseTest)1