MessageForwarder2 Class — netty Architecture
Architecture documentation for the MessageForwarder2 class in LocalTransportThreadModelTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c6804a8c_0e01_672c_fdc2_bb603d65f827["MessageForwarder2"] adb139e6_2a46_ab0a_b143_d2609be299b3["LocalTransportThreadModelTest.java"] c6804a8c_0e01_672c_fdc2_bb603d65f827 -->|defined in| adb139e6_2a46_ab0a_b143_d2609be299b3 2a2ccd44_c11c_349c_5ccf_54de69e96fa2["channelRead()"] c6804a8c_0e01_672c_fdc2_bb603d65f827 -->|method| 2a2ccd44_c11c_349c_5ccf_54de69e96fa2 20aebb20_729f_a10e_ef12_e4f1b72c2eb5["write()"] c6804a8c_0e01_672c_fdc2_bb603d65f827 -->|method| 20aebb20_729f_a10e_ef12_e4f1b72c2eb5 7db1d4d5_b1f1_3200_b2f8_b6807c472b23["exceptionCaught()"] c6804a8c_0e01_672c_fdc2_bb603d65f827 -->|method| 7db1d4d5_b1f1_3200_b2f8_b6807c472b23
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java lines 474–521
private static class MessageForwarder2 extends ChannelDuplexHandler {
private final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
private volatile int inCnt;
private volatile int outCnt;
private volatile Thread t;
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Thread t = this.t;
if (t == null) {
this.t = Thread.currentThread();
} else {
assertSame(t, Thread.currentThread());
}
ByteBuf m = (ByteBuf) msg;
int count = m.readableBytes() / 4;
for (int j = 0; j < count; j ++) {
int actual = m.readInt();
int expected = inCnt ++;
assertEquals(expected, actual);
ctx.fireChannelRead(actual);
}
m.release();
}
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
assertSame(t, Thread.currentThread());
ByteBuf out = ctx.alloc().buffer(4);
int m = (Integer) msg;
int expected = outCnt ++;
assertEquals(expected, m);
out.writeInt(m);
ctx.write(out, promise);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
exception.compareAndSet(null, cause);
//System.err.print("[" + Thread.currentThread().getName() + "] ");
//cause.printStackTrace();
super.exceptionCaught(ctx, cause);
}
}
Source
Frequently Asked Questions
What is the MessageForwarder2 class?
MessageForwarder2 is a class in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java.
Where is MessageForwarder2 defined?
MessageForwarder2 is defined in transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java at line 474.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free