testStopConsumingChunksWhenFailed() — netty Function Reference
Architecture documentation for the testStopConsumingChunksWhenFailed() function in ChunkedWriteHandlerTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 8f834f33_0a6b_5621_a20e_9d424b9c02c2["testStopConsumingChunksWhenFailed()"] 56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb["ChunkedWriteHandlerTest"] 8f834f33_0a6b_5621_a20e_9d424b9c02c2 -->|defined in| 56a5cec9_e7c0_8a2d_a9b0_56df2226f2bb 9868e6d9_223c_5ab4_8019_7000479136c4["isEndOfInput()"] 8f834f33_0a6b_5621_a20e_9d424b9c02c2 -->|calls| 9868e6d9_223c_5ab4_8019_7000479136c4 08c92a94_2d5f_1e52_610b_f1d9d0eae0c2["close()"] 8f834f33_0a6b_5621_a20e_9d424b9c02c2 -->|calls| 08c92a94_2d5f_1e52_610b_f1d9d0eae0c2 065d12a2_1432_c5fd_404a_8b3282ea3171["length()"] 8f834f33_0a6b_5621_a20e_9d424b9c02c2 -->|calls| 065d12a2_1432_c5fd_404a_8b3282ea3171 a977f573_a177_e786_c51c_5e5a05d2b25e["progress()"] 8f834f33_0a6b_5621_a20e_9d424b9c02c2 -->|calls| a977f573_a177_e786_c51c_5e5a05d2b25e style 8f834f33_0a6b_5621_a20e_9d424b9c02c2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java lines 414–471
@Test
public void testStopConsumingChunksWhenFailed() {
final ByteBuf buffer = Unpooled.copiedBuffer("Test", CharsetUtil.ISO_8859_1);
final AtomicInteger chunks = new AtomicInteger(0);
ChunkedInput<ByteBuf> nonClosableInput = new ChunkedInput<ByteBuf>() {
@Override
public boolean isEndOfInput() throws Exception {
return chunks.get() >= 5;
}
@Override
public void close() throws Exception {
// no-op
}
@Deprecated
@Override
public ByteBuf readChunk(ChannelHandlerContext ctx) throws Exception {
return readChunk(ctx.alloc());
}
@Override
public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception {
chunks.incrementAndGet();
return buffer.retainedDuplicate();
}
@Override
public long length() {
return -1;
}
@Override
public long progress() {
return 1;
}
};
ChannelOutboundHandlerAdapter noOpWrites = new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
ReferenceCountUtil.release(msg);
promise.tryFailure(new RuntimeException());
}
};
EmbeddedChannel ch = new EmbeddedChannel(noOpWrites, new ChunkedWriteHandler());
ch.writeAndFlush(nonClosableInput).awaitUninterruptibly();
// Should be `false` as we do not expect any messages to be written
assertFalse(ch.finish());
buffer.release();
// We should expect only single chunked being read from the input.
// It's possible to get a race condition here between resolving a promise and
// allocating a new chunk, but should be fine when working with embedded channels.
assertEquals(1, chunks.get());
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testStopConsumingChunksWhenFailed() do?
testStopConsumingChunksWhenFailed() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java.
Where is testStopConsumingChunksWhenFailed() defined?
testStopConsumingChunksWhenFailed() is defined in handler/src/test/java/io/netty/handler/stream/ChunkedWriteHandlerTest.java at line 414.
What does testStopConsumingChunksWhenFailed() call?
testStopConsumingChunksWhenFailed() 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