Home / Class/ ReadAndDiscardHandler Class — netty Architecture

ReadAndDiscardHandler Class — netty Architecture

Architecture documentation for the ReadAndDiscardHandler class in SocketSslSessionReuseTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  30ffab1a_630f_7349_506d_0e1ab9a85508["ReadAndDiscardHandler"]
  5db688ae_c289_64df_2763_37867a6d3ea4["SocketSslSessionReuseTest.java"]
  30ffab1a_630f_7349_506d_0e1ab9a85508 -->|defined in| 5db688ae_c289_64df_2763_37867a6d3ea4
  48bf9a56_8c75_7caf_da59_f5393321189e["ReadAndDiscardHandler()"]
  30ffab1a_630f_7349_506d_0e1ab9a85508 -->|method| 48bf9a56_8c75_7caf_da59_f5393321189e
  0afc76ed_f0a6_b205_4d3f_ec13f80850a6["channelRead0()"]
  30ffab1a_630f_7349_506d_0e1ab9a85508 -->|method| 0afc76ed_f0a6_b205_4d3f_ec13f80850a6
  2b246c01_bc81_be85_611f_aa9143ff26e3["channelReadComplete()"]
  30ffab1a_630f_7349_506d_0e1ab9a85508 -->|method| 2b246c01_bc81_be85_611f_aa9143ff26e3
  90347a10_087a_85cd_4889_d7b9aeef4ad5["exceptionCaught()"]
  30ffab1a_630f_7349_506d_0e1ab9a85508 -->|method| 90347a10_087a_85cd_4889_d7b9aeef4ad5

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java lines 288–326

    @Sharable
    private static class ReadAndDiscardHandler extends SimpleChannelInboundHandler<ByteBuf> {
        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
        private final boolean server;
        private final boolean autoRead;

        ReadAndDiscardHandler(boolean server, boolean autoRead) {
            this.server = server;
            this.autoRead = autoRead;
        }

        @Override
        public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
            in.skipBytes(in.readableBytes());
        }

        @Override
        public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
            try {
                ctx.flush();
            } finally {
                if (!autoRead) {
                    ctx.read();
                }
            }
        }

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

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

Frequently Asked Questions

What is the ReadAndDiscardHandler class?
ReadAndDiscardHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java.
Where is ReadAndDiscardHandler defined?
ReadAndDiscardHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketSslSessionReuseTest.java at line 288.

Analyze Your Own Codebase

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

Try Supermodel Free