Home / Function/ testHandshakeTimeoutBecauseExecutorNotExecute() — netty Function Reference

testHandshakeTimeoutBecauseExecutorNotExecute() — netty Function Reference

Architecture documentation for the testHandshakeTimeoutBecauseExecutorNotExecute() function in SslHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f3fa1007_2068_3239_cb9b_80fec8671dd1["testHandshakeTimeoutBecauseExecutorNotExecute()"]
  adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"]
  f3fa1007_2068_3239_cb9b_80fec8671dd1 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e
  697f9333_e796_43fc_9825_9feae67554c3["testClientHandshakeTimeoutBecauseExecutorNotExecute()"]
  697f9333_e796_43fc_9825_9feae67554c3 -->|calls| f3fa1007_2068_3239_cb9b_80fec8671dd1
  acb3eabc_90a4_9896_e70f_c4e019606dbb["testServerHandshakeTimeoutBecauseExecutorNotExecute()"]
  acb3eabc_90a4_9896_e70f_c4e019606dbb -->|calls| f3fa1007_2068_3239_cb9b_80fec8671dd1
  style f3fa1007_2068_3239_cb9b_80fec8671dd1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 1179–1253

    private static void testHandshakeTimeoutBecauseExecutorNotExecute(final boolean client) throws Exception {
        final SslContext sslClientCtx = SslContextBuilder.forClient()
                .trustManager(InsecureTrustManagerFactory.INSTANCE)
                .sslProvider(SslProvider.JDK).build();

        final SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
        final SslContext sslServerCtx = SslContextBuilder.forServer(cert.key(), cert.cert())
                .sslProvider(SslProvider.JDK).build();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        Channel sc = null;
        Channel cc = null;
        final SslHandler clientSslHandler = sslClientCtx.newHandler(UnpooledByteBufAllocator.DEFAULT, new Executor() {
            @Override
            public void execute(Runnable command) {
                if (!client) {
                    command.run();
                }
                // Do nothing to simulate slow execution.
            }
        });
        if (client) {
            clientSslHandler.setHandshakeTimeout(100, TimeUnit.MILLISECONDS);
        }
        final SslHandler serverSslHandler = sslServerCtx.newHandler(UnpooledByteBufAllocator.DEFAULT, new Executor() {
            @Override
            public void execute(Runnable command) {
                if (client) {
                    command.run();
                }
                // Do nothing to simulate slow execution.
            }
        });
        if (!client) {
            serverSslHandler.setHandshakeTimeout(100, TimeUnit.MILLISECONDS);
        }
        try {
            sc = new ServerBootstrap()
                    .group(group)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(serverSslHandler)
                    .bind(new InetSocketAddress(0)).syncUninterruptibly().channel();

            ChannelFuture future = new Bootstrap()
                    .group(group)
                    .channel(NioSocketChannel.class)
                    .handler(new ChannelInitializer<Channel>() {
                        @Override
                        protected void initChannel(Channel ch) {
                            ch.pipeline().addLast(clientSslHandler);
                        }
                    }).connect(sc.localAddress());
            cc = future.syncUninterruptibly().channel();

            if (client) {
                Throwable cause = clientSslHandler.handshakeFuture().await().cause();
                assertInstanceOf(SslHandshakeTimeoutException.class, cause);
                assertFalse(serverSslHandler.handshakeFuture().await().isSuccess());
            } else {
                Throwable cause = serverSslHandler.handshakeFuture().await().cause();
                assertInstanceOf(SslHandshakeTimeoutException.class, cause);
                assertFalse(clientSslHandler.handshakeFuture().await().isSuccess());
            }
        } finally {
            if (cc != null) {
                cc.close().syncUninterruptibly();
            }
            if (sc != null) {
                sc.close().syncUninterruptibly();
            }
            group.shutdownGracefully();
            ReferenceCountUtil.release(sslClientCtx);
            ReferenceCountUtil.release(sslServerCtx);
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testHandshakeTimeoutBecauseExecutorNotExecute() do?
testHandshakeTimeoutBecauseExecutorNotExecute() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is testHandshakeTimeoutBecauseExecutorNotExecute() defined?
testHandshakeTimeoutBecauseExecutorNotExecute() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 1179.
What calls testHandshakeTimeoutBecauseExecutorNotExecute()?
testHandshakeTimeoutBecauseExecutorNotExecute() is called by 2 function(s): testClientHandshakeTimeoutBecauseExecutorNotExecute, testServerHandshakeTimeoutBecauseExecutorNotExecute.

Analyze Your Own Codebase

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

Try Supermodel Free