Home / Function/ ChannelHandler() — netty Function Reference

ChannelHandler() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  7de25b08_660b_921c_cc1e_43699a7be046["ChannelHandler()"]
  adaf7dc7_94e2_152f_ffdb_453fdaa4f25e["SslHandlerTest"]
  7de25b08_660b_921c_cc1e_43699a7be046 -->|defined in| adaf7dc7_94e2_152f_ffdb_453fdaa4f25e
  style 7de25b08_660b_921c_cc1e_43699a7be046 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java lines 506–544

    private static ChannelHandler newHandler(final SslContext sslCtx, final Promise<Void> promise) {
        return new ChannelInitializer() {
            @Override
            protected void initChannel(final Channel ch) {
                final SslHandler sslHandler = sslCtx.newHandler(ch.alloc());
                sslHandler.setHandshakeTimeoutMillis(1000);
                ch.pipeline().addFirst(sslHandler);
                sslHandler.handshakeFuture().addListener(future -> {
                    ch.pipeline().remove(sslHandler);

                    // Schedule the close so removal has time to propagate exception if any.
                    ch.eventLoop().execute(new Runnable() {
                        @Override
                        public void run() {
                            ch.close();
                        }
                    });
                });

                ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
                    @Override
                    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
                        if (cause instanceof CodecException) {
                            cause = cause.getCause();
                        }
                        if (cause instanceof IllegalReferenceCountException) {
                            promise.setFailure(cause);
                        }
                    }

                    @Override
                    public void channelInactive(ChannelHandlerContext ctx) {
                        promise.trySuccess(null);
                        ReferenceCountUtil.release(sslCtx);
                    }
                });
            }
        };
    }

Domain

Subdomains

Frequently Asked Questions

What does ChannelHandler() do?
ChannelHandler() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java.
Where is ChannelHandler() defined?
ChannelHandler() is defined in handler/src/test/java/io/netty/handler/ssl/SslHandlerTest.java at line 506.

Analyze Your Own Codebase

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

Try Supermodel Free