Ejemplo n.º 1
0
  // See https://github.com/netty/netty/issues/3967
  @Test
  public void testCloseChannelOnCreation() {
    EmbeddedChannel channel = new EmbeddedChannel();
    channel.close().syncUninterruptibly();

    final PendingWriteQueue queue = new PendingWriteQueue(channel.pipeline().firstContext());

    IllegalStateException ex = new IllegalStateException();
    ChannelPromise promise = channel.newPromise();
    queue.add(1L, promise);
    queue.removeAndFailAll(ex);
    assertSame(ex, promise.cause());
  }
Ejemplo n.º 2
0
  @Test
  public void testRemoveAndFailAllReentrance() {
    EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter());
    final PendingWriteQueue queue = new PendingWriteQueue(channel.pipeline().firstContext());

    ChannelPromise promise = channel.newPromise();
    promise.addListener(
        new ChannelFutureListener() {
          @Override
          public void operationComplete(ChannelFuture future) throws Exception {
            queue.removeAndFailAll(new IllegalStateException());
          }
        });
    queue.add(1L, promise);

    ChannelPromise promise2 = channel.newPromise();
    queue.add(2L, promise2);
    queue.removeAndFailAll(new Exception());
    assertFalse(promise.isSuccess());
    assertFalse(promise2.isSuccess());
    assertFalse(channel.finish());
  }