testCloseInWritePromiseCompletePreservesOrder() — netty Function Reference
Architecture documentation for the testCloseInWritePromiseCompletePreservesOrder() function in LocalChannelTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 316e8485_bea4_4814_7c9e_95f0c3153153["testCloseInWritePromiseCompletePreservesOrder()"] d7e5442a_9b99_814d_2bd6_0be57237db65["LocalChannelTest"] 316e8485_bea4_4814_7c9e_95f0c3153153 -->|defined in| d7e5442a_9b99_814d_2bd6_0be57237db65 d3c8aa54_ac5d_6944_e789_c2c22ce16089["closeChannel()"] 316e8485_bea4_4814_7c9e_95f0c3153153 -->|calls| d3c8aa54_ac5d_6944_e789_c2c22ce16089 c89c9d89_4030_c998_7504_cb2fa2ef2bc8["channelRead()"] 316e8485_bea4_4814_7c9e_95f0c3153153 -->|calls| c89c9d89_4030_c998_7504_cb2fa2ef2bc8 style 316e8485_bea4_4814_7c9e_95f0c3153153 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
transport/src/test/java/io/netty/channel/local/LocalChannelTest.java lines 332–392
@Test
public void testCloseInWritePromiseCompletePreservesOrder() throws InterruptedException {
Bootstrap cb = new Bootstrap();
ServerBootstrap sb = new ServerBootstrap();
final CountDownLatch messageLatch = new CountDownLatch(2);
final ByteBuf data = Unpooled.wrappedBuffer(new byte[1024]);
try {
cb.group(group1)
.channel(LocalChannel.class)
.handler(new TestHandler());
sb.group(group2)
.channel(LocalServerChannel.class)
.childHandler(new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg.equals(data)) {
ReferenceCountUtil.safeRelease(msg);
messageLatch.countDown();
} else {
super.channelRead(ctx, msg);
}
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
messageLatch.countDown();
super.channelInactive(ctx);
}
});
Channel sc = null;
Channel cc = null;
try {
// Start server
sc = sb.bind(TEST_ADDRESS).syncUninterruptibly().channel();
// Connect to the server
cc = cb.connect(sc.localAddress()).syncUninterruptibly().channel();
final Channel ccCpy = cc;
// Make sure a write operation is executed in the eventloop
cc.pipeline().lastContext().executor().execute(new Runnable() {
@Override
public void run() {
ChannelPromise promise = ccCpy.newPromise();
promise.addListener(future -> ccCpy.pipeline().lastContext().close());
ccCpy.writeAndFlush(data.retainedDuplicate(), promise);
}
});
assertTrue(messageLatch.await(5, SECONDS));
assertFalse(cc.isOpen());
} finally {
closeChannel(cc);
closeChannel(sc);
}
} finally {
data.release();
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testCloseInWritePromiseCompletePreservesOrder() do?
testCloseInWritePromiseCompletePreservesOrder() is a function in the netty codebase, defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java.
Where is testCloseInWritePromiseCompletePreservesOrder() defined?
testCloseInWritePromiseCompletePreservesOrder() is defined in transport/src/test/java/io/netty/channel/local/LocalChannelTest.java at line 332.
What does testCloseInWritePromiseCompletePreservesOrder() call?
testCloseInWritePromiseCompletePreservesOrder() calls 2 function(s): channelRead, closeChannel.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free