Home / Function/ testReleasesOnShrink2() — netty Function Reference

testReleasesOnShrink2() — netty Function Reference

Architecture documentation for the testReleasesOnShrink2() function in AbstractCompositeByteBufTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  7cb2bab6_a8ba_ad33_d383_2afe6a44a3ea["testReleasesOnShrink2()"]
  47bc0a20_e243_89ff_132b_99ac6b23835f["AbstractCompositeByteBufTest"]
  7cb2bab6_a8ba_ad33_d383_2afe6a44a3ea -->|defined in| 47bc0a20_e243_89ff_132b_99ac6b23835f
  style 7cb2bab6_a8ba_ad33_d383_2afe6a44a3ea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java lines 1387–1419

    @Test
    public void testReleasesOnShrink2() {
        // It is important to use a pooled allocator here to ensure
        // the slices returned by readRetainedSlice are of type
        // PooledSlicedByteBuf, which maintains an independent refcount
        // (so that we can be sure to cover this case)
        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();

        buffer.writeShort(1).writeShort(2);

        ByteBuf b1 = buffer.readRetainedSlice(2);
        ByteBuf b2 = b1.retainedSlice(b1.readerIndex(), 2);

        // composite takes ownership of b1 and b2
        ByteBuf composite = newCompositeBuffer()
            .addComponents(b1, b2);

        assertEquals(4, composite.capacity());

        // reduce capacity down to two, will drop the second component
        composite.capacity(2);
        assertEquals(2, composite.capacity());

        // releasing composite should release the components
        composite.release();
        assertEquals(0, composite.refCnt());
        assertEquals(0, b1.refCnt());
        assertEquals(0, b2.refCnt());

        // release last remaining ref to buffer
        buffer.release();
        assertEquals(0, buffer.refCnt());
    }

Domain

Subdomains

Frequently Asked Questions

What does testReleasesOnShrink2() do?
testReleasesOnShrink2() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java.
Where is testReleasesOnShrink2() defined?
testReleasesOnShrink2() is defined in buffer/src/test/java/io/netty/buffer/AbstractCompositeByteBufTest.java at line 1387.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free