TestHandler Class — netty Architecture
Architecture documentation for the TestHandler class in SocketShutdownOutputBySelfTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD b34e73fd_ffda_8fdb_8c3d_2880f25215d7["TestHandler"] db2ccfc3_8846_6680_0c40_6e29d05f53d5["SocketShutdownOutputBySelfTest.java"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|defined in| db2ccfc3_8846_6680_0c40_6e29d05f53d5 2a5b6e7f_e1d8_0629_bf15_5f9baf3a53e1["channelWritabilityChanged()"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|method| 2a5b6e7f_e1d8_0629_bf15_5f9baf3a53e1 746dc5c8_e4df_e830_3dbe_182ce623a769["channelActive()"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|method| 746dc5c8_e4df_e830_3dbe_182ce623a769 4475071a_b852_9559_1e89_928e64d3601d["channelRead0()"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|method| 4475071a_b852_9559_1e89_928e64d3601d c860c19a_9228_801f_c266_024d188f0855["drainWritabilityQueue()"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|method| c860c19a_9228_801f_c266_024d188f0855 b68d4b5a_c157_7afe_19c8_50d40f7fff03["assertWritability()"] b34e73fd_ffda_8fdb_8c3d_2880f25215d7 -->|method| b68d4b5a_c157_7afe_19c8_50d40f7fff03
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java lines 285–321
private static final class TestHandler extends SimpleChannelInboundHandler<ByteBuf> {
volatile SocketChannel ch;
final BlockingQueue<Byte> queue = new LinkedBlockingQueue<Byte>();
final BlockingDeque<Boolean> writabilityQueue = new LinkedBlockingDeque<Boolean>();
@Override
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
writabilityQueue.add(ctx.channel().isWritable());
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ch = (SocketChannel) ctx.channel();
}
@Override
public void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
queue.offer(msg.readByte());
}
private void drainWritabilityQueue() throws InterruptedException {
while ((writabilityQueue.poll(100, TimeUnit.MILLISECONDS)) != null) {
// Just drain the queue.
}
}
void assertWritability(boolean isWritable) throws InterruptedException {
try {
Boolean writability = writabilityQueue.takeLast();
assertEquals(isWritable, writability);
// TODO(scott): why do we get multiple writability changes here ... race condition?
drainWritabilityQueue();
} catch (Throwable c) {
c.printStackTrace();
}
}
}
Defined In
Source
Frequently Asked Questions
What is the TestHandler class?
TestHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java.
Where is TestHandler defined?
TestHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketShutdownOutputBySelfTest.java at line 285.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free