Home / Class/ EchoHandler Class — netty Architecture

EchoHandler Class — netty Architecture

Architecture documentation for the EchoHandler class in SocketSslEchoTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b174b817_9190_cba2_8482_75fcf900d711["EchoHandler"]
  34cf25cc_6ea4_21b4_4971_fbf3fd40752e["SocketSslEchoTest.java"]
  b174b817_9190_cba2_8482_75fcf900d711 -->|defined in| 34cf25cc_6ea4_21b4_4971_fbf3fd40752e
  423b4331_6b5e_7fcb_8166_bd73d30dd82e["EchoHandler()"]
  b174b817_9190_cba2_8482_75fcf900d711 -->|method| 423b4331_6b5e_7fcb_8166_bd73d30dd82e
  3121b1c5_0285_3e1c_d18e_e06dfab83945["channelReadComplete()"]
  b174b817_9190_cba2_8482_75fcf900d711 -->|method| 3121b1c5_0285_3e1c_d18e_e06dfab83945
  77c8e10b_0a5d_6b1f_d4a9_41857123f9e5["userEventTriggered()"]
  b174b817_9190_cba2_8482_75fcf900d711 -->|method| 77c8e10b_0a5d_6b1f_d4a9_41857123f9e5
  d1f0252c_fa0a_9b62_e2c2_8f78c08a3c04["exceptionCaught()"]
  b174b817_9190_cba2_8482_75fcf900d711 -->|method| d1f0252c_fa0a_9b62_e2c2_8f78c08a3c04

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java lines 455–504

    @Sharable
    private abstract class EchoHandler extends SimpleChannelInboundHandler<ByteBuf> {

        protected final AtomicInteger recvCounter;
        protected final AtomicInteger negoCounter;
        protected final AtomicReference<Throwable> exception;

        EchoHandler(
                AtomicInteger recvCounter, AtomicInteger negoCounter,
                AtomicReference<Throwable> exception) {

            this.recvCounter = recvCounter;
            this.negoCounter = negoCounter;
            this.exception = exception;
        }

        @Override
        public final void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
            // We intentionally do not ctx.flush() here because we want to verify the SslHandler correctly flushing
            // non-application and previously flushed writes internally.
            if (!autoRead) {
                ctx.read();
            }
            ctx.fireChannelReadComplete();
        }

        @Override
        public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
            if (evt instanceof SslHandshakeCompletionEvent) {
                SslHandshakeCompletionEvent handshakeEvt = (SslHandshakeCompletionEvent) evt;
                if (handshakeEvt.cause() != null) {
                    logger.warn("Handshake failed:", handshakeEvt.cause());
                }
                assertSame(SslHandshakeCompletionEvent.SUCCESS, evt);
                negoCounter.incrementAndGet();
                logStats("HANDSHAKEN");
            }
            ctx.fireUserEventTriggered(evt);
        }

        @Override
        public final void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
            if (logger.isWarnEnabled()) {
                logger.warn("Unexpected exception from the client side:", cause);
            }

            exception.compareAndSet(null, cause);
            ctx.close();
        }
    }

Frequently Asked Questions

What is the EchoHandler class?
EchoHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java.
Where is EchoHandler defined?
EchoHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java at line 455.

Analyze Your Own Codebase

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

Try Supermodel Free