Home / Class/ Http2StreamChannelBootstrapTest Class — netty Architecture

Http2StreamChannelBootstrapTest Class — netty Architecture

Architecture documentation for the Http2StreamChannelBootstrapTest class in Http2StreamChannelBootstrapTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  50eedf11_f660_dc20_71c5_c1d7bf019f90["Http2StreamChannelBootstrapTest"]
  6a4bfac4_61df_b162_f47b_fa5c35c40b33["Http2StreamChannelBootstrapTest.java"]
  50eedf11_f660_dc20_71c5_c1d7bf019f90 -->|defined in| 6a4bfac4_61df_b162_f47b_fa5c35c40b33
  768ceffc_b61a_dc82_8899_9268f03c871d["testStreamIsNotCreatedIfParentConnectionIsClosedConcurrently()"]
  50eedf11_f660_dc20_71c5_c1d7bf019f90 -->|method| 768ceffc_b61a_dc82_8899_9268f03c871d
  55bcd333_86e0_abba_a434_4152c1517f1f["Http2MultiplexHandler()"]
  50eedf11_f660_dc20_71c5_c1d7bf019f90 -->|method| 55bcd333_86e0_abba_a434_4152c1517f1f
  563e09b0_5a75_8d0e_fff1_ead4c30f71fe["safeClose()"]
  50eedf11_f660_dc20_71c5_c1d7bf019f90 -->|method| 563e09b0_5a75_8d0e_fff1_ead4c30f71fe
  f8adc3db_2606_20ae_9c96_1307c036432c["open0FailsPromiseOnHttp2MultiplexHandlerError()"]
  50eedf11_f660_dc20_71c5_c1d7bf019f90 -->|method| f8adc3db_2606_20ae_9c96_1307c036432c

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrapTest.java lines 51–164

public class Http2StreamChannelBootstrapTest {

    private static final InternalLogger logger =
            InternalLoggerFactory.getInstance(Http2StreamChannelBootstrapTest.class);

    private volatile Channel serverConnectedChannel;

    @Test
    public void testStreamIsNotCreatedIfParentConnectionIsClosedConcurrently() throws Exception {
        EventLoopGroup group = null;
        Channel serverChannel = null;
        Channel clientChannel = null;
        try {
            final CountDownLatch serverChannelLatch = new CountDownLatch(1);
            group = new DefaultEventLoop();
            LocalAddress serverAddress = new LocalAddress(getClass().getName());
            ServerBootstrap sb = new ServerBootstrap()
                    .channel(LocalServerChannel.class)
                    .group(group)
                    .childHandler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) {
                            serverConnectedChannel = ch;
                            ch.pipeline().addLast(forServer().build(), newMultiplexedHandler());
                            serverChannelLatch.countDown();
                        }
                    });
            serverChannel = sb.bind(serverAddress).sync().channel();

            Bootstrap cb = new Bootstrap()
                    .channel(LocalChannel.class)
                    .group(group)
                    .handler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) {
                            ch.pipeline().addLast(forClient().build(), newMultiplexedHandler());
                        }
                    });
            clientChannel = cb.connect(serverAddress).sync().channel();
            assertTrue(serverChannelLatch.await(3, SECONDS));

            final CountDownLatch closeLatch = new CountDownLatch(1);
            final Channel clientChannelToClose = clientChannel;
            group.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        closeLatch.await();
                        clientChannelToClose.close().syncUninterruptibly();
                    } catch (InterruptedException e) {
                        logger.error(e);
                    }
                }
            });

            Http2StreamChannelBootstrap bootstrap = new Http2StreamChannelBootstrap(clientChannel);
            final Promise<Http2StreamChannel> promise = clientChannel.eventLoop().newPromise();
            bootstrap.open(promise);
            assertFalse(promise.isDone());
            closeLatch.countDown();

            ExecutionException exception = assertThrows(ExecutionException.class, new Executable() {
                @Override
                public void execute() throws Throwable {
                    promise.get(3, SECONDS);
                }
            });
            assertInstanceOf(ClosedChannelException.class, exception.getCause());
        } finally {
            safeClose(clientChannel);
            safeClose(serverConnectedChannel);
            safeClose(serverChannel);
            if (group != null) {
                group.shutdownGracefully(0, 3, SECONDS);
            }
        }
    }

    private static Http2MultiplexHandler newMultiplexedHandler() {
        return new Http2MultiplexHandler(new ChannelInitializer<Http2StreamChannel>() {
            @Override

Frequently Asked Questions

What is the Http2StreamChannelBootstrapTest class?
Http2StreamChannelBootstrapTest is a class in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrapTest.java.
Where is Http2StreamChannelBootstrapTest defined?
Http2StreamChannelBootstrapTest is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/Http2StreamChannelBootstrapTest.java at line 51.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free