Home / Function/ testDiscardPendingWritesOnInactive() — netty Function Reference

testDiscardPendingWritesOnInactive() — netty Function Reference

Architecture documentation for the testDiscardPendingWritesOnInactive() function in ChunkedWriteHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2["testDiscardPendingWritesOnInactive()"]
  56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb["ChunkedWriteHandlerTest"]
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2 -->|defined in| 56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb
  9868e6d9_223c_5ab4_8019_7000479136c4["isEndOfInput()"]
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2 -->|calls| 9868e6d9_223c_5ab4_8019_7000479136c4
  08c92a94_2d5f_1e52_610b_f1d9d0eae0c2["close()"]
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2 -->|calls| 08c92a94_2d5f_1e52_610b_f1d9d0eae0c2
  065d12a2_1432_c5fd_404a_8b3282ea3171["length()"]
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2 -->|calls| 065d12a2_1432_c5fd_404a_8b3282ea3171
  a977f573_a177_e786_c51c_5e5a05d2b25e["progress()"]
  9cab7b07_3bcf_70e4_a7b3_1933d00731c2 -->|calls| a977f573_a177_e786_c51c_5e5a05d2b25e
  style 9cab7b07_3bcf_70e4_a7b3_1933d00731c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java lines 352–411

    @Test
    public void testDiscardPendingWritesOnInactive() throws IOException {

        final AtomicBoolean closeWasCalled = new AtomicBoolean(false);

        ChunkedInput<ByteBuf> notifiableInput = new ChunkedInput<ByteBuf>() {
            private boolean done;
            private final ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1);

            @Override
            public boolean isEndOfInput() throws Exception {
                return done;
            }

            @Override
            public void close() throws Exception {
                buffer.release();
                closeWasCalled.set(true);
            }

            @Deprecated
            @Override
            public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
                return readChunk(ctx.alloc());
            }

            @Override
            public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception {
                if (done) {
                    return null;
                }
                done = true;
                return buffer.retainedDuplicate();
            }

            @Override
            public long length() {
                return -1;
            }

            @Override
            public long progress() {
                return 1;
            }
        };

        EmbeddedChannel ch = new EmbeddedChannel(new ChunkedWriteHandler());

        // Write 3 messages and close channel before flushing
        ChannelFuture r1 = ch.write(new ChunkedFile(TMP));
        ChannelFuture r2 = ch.write(new ChunkedNioFile(TMP));
        ch.write(notifiableInput);

        // Should be `false` as we do not expect any messages to be written
        assertFalse(ch.finish());

        assertFalse(r1.isSuccess());
        assertFalse(r2.isSuccess());
        assertTrue(closeWasCalled.get());
    }

Domain

Subdomains

Frequently Asked Questions

What does testDiscardPendingWritesOnInactive() do?
testDiscardPendingWritesOnInactive() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java.
Where is testDiscardPendingWritesOnInactive() defined?
testDiscardPendingWritesOnInactive() is defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java at line 352.
What does testDiscardPendingWritesOnInactive() call?
testDiscardPendingWritesOnInactive() calls 4 function(s): close, isEndOfInput, length, progress.

Analyze Your Own Codebase

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

Try Supermodel Free