el
el copied to clipboard
When `register()` eventLoop on the channel, waiting for all handlers done its event handling?
ChannelEventLoop eventLoop = mock(ChannelEventLoop.class);
when(eventLoop.inEventLoop()).thenReturn(true);
TestInboundHandler handler = new TestInboundHandler() {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
latch.countDown();
}
};
TestChannel channel = new TestChannel();
channel.pipeline().addLast(handler);
ChannelPromise promise = new DefaultChannelPromise(channel, eventLoop);
channel.internal().register(eventLoop, promise);
promise.await();
When promise.await() is done, someone might expect all event handler calls done successfully. But in the code, registering the event loop on the channel and calling all event handlers are asynchronous. So although promise is done with success, some event handlers could be failed