AutoReadHandler Class — netty Architecture
Architecture documentation for the AutoReadHandler class in SocketAutoReadTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 54eba447_08e7_08fe_25cd_f47eb3c99e5a["AutoReadHandler"] 9b48ca78_1238_62ed_f777_a60e46d03430["SocketAutoReadTest.java"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|defined in| 9b48ca78_1238_62ed_f777_a60e46d03430 4a526c8c_f39d_3bbd_554b_b79bd81141ea["AutoReadHandler()"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|method| 4a526c8c_f39d_3bbd_554b_b79bd81141ea 5354ae69_2a7d_32f3_2ac2_b96eb6a502a3["channelRead()"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|method| 5354ae69_2a7d_32f3_2ac2_b96eb6a502a3 8c3f5fae_ae34_bdda_f8c8_d2292dd2b0f8["channelReadComplete()"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|method| 8c3f5fae_ae34_bdda_f8c8_d2292dd2b0f8 d9d4f82a_5388_2930_0a36_3dd4ddd5232b["assertSingleRead()"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|method| d9d4f82a_5388_2930_0a36_3dd4ddd5232b 7daee521_e26c_2607_1702_5a2f3d5d554c["assertSingleReadSecondTry()"] 54eba447_08e7_08fe_25cd_f47eb3c99e5a -->|method| 7daee521_e26c_2607_1702_5a2f3d5d554c
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java lines 126–164
private static final class AutoReadHandler extends ChannelInboundHandlerAdapter {
private final AtomicInteger count = new AtomicInteger();
private final CountDownLatch latch = new CountDownLatch(1);
private final CountDownLatch latch2;
private final boolean callRead;
AutoReadHandler(boolean callRead) {
this.callRead = callRead;
latch2 = new CountDownLatch(callRead ? 3 : 2);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ReferenceCountUtil.release(msg);
if (count.incrementAndGet() == 1) {
ctx.channel().config().setAutoRead(false);
}
if (callRead) {
// Test calling read in the EventLoop thread to ensure a read is eventually done.
ctx.read();
}
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
latch.countDown();
latch2.countDown();
}
void assertSingleRead() throws InterruptedException {
assertTrue(latch.await(5, TimeUnit.SECONDS));
assertTrue(count.get() > 0);
}
void assertSingleReadSecondTry() throws InterruptedException {
assertTrue(latch2.await(5, TimeUnit.SECONDS));
assertEquals(callRead ? 3 : 2, count.get());
}
}
Source
Frequently Asked Questions
What is the AutoReadHandler class?
AutoReadHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java.
Where is AutoReadHandler defined?
AutoReadHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketAutoReadTest.java at line 126.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free