el icon indicating copy to clipboard operation
el copied to clipboard

When `register()` eventLoop on the channel, waiting for all handlers done its event handling?

Open zeroFruit opened this issue 3 years ago • 0 comments

      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

zeroFruit avatar May 28 '22 07:05 zeroFruit