Home / Class/ SslTasksRunner Class — netty Architecture

SslTasksRunner Class — netty Architecture

Architecture documentation for the SslTasksRunner class in SslHandler.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  4971d882_98ff_3ffd_f66b_31ea649497b3["SslTasksRunner"]
  cdb86368_ae5f_5721_2e99_c3d0ec92017f["SslHandler.java"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|defined in| cdb86368_ae5f_5721_2e99_c3d0ec92017f
  61e05d6f_34cf_cd60_56f5_2ef47f00b3b0["SslTasksRunner()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 61e05d6f_34cf_cd60_56f5_2ef47f00b3b0
  8cae5f97_939d_55fc_31c2_c6131add51c2["taskError()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 8cae5f97_939d_55fc_31c2_c6131add51c2
  6f2ad3ca_d892_92d8_e5db_c67eb1473ab2["safeExceptionCaught()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 6f2ad3ca_d892_92d8_e5db_c67eb1473ab2
  6a6c9f71_8d6b_1ed2_787c_12fbd8c1c17c["Throwable()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 6a6c9f71_8d6b_1ed2_787c_12fbd8c1c17c
  f221057f_9b44_cc50_e4e5_62605fce7fe9["tryDecodeAgain()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| f221057f_9b44_cc50_e4e5_62605fce7fe9
  3767fed6_8ef0_e61c_ca65_bd1e0902b8bb["resumeOnEventExecutor()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 3767fed6_8ef0_e61c_ca65_bd1e0902b8bb
  cb55a9c1_7a30_c86d_8180_17c1a46f16de["runComplete()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| cb55a9c1_7a30_c86d_8180_17c1a46f16de
  3832f383_3ba5_2efc_b7fe_c77da2d88b3e["run()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 3832f383_3ba5_2efc_b7fe_c77da2d88b3e
  8c148524_5863_9fd9_17ef_b36c8e32fd70["handleException()"]
  4971d882_98ff_3ffd_f66b_31ea649497b3 -->|method| 8c148524_5863_9fd9_17ef_b36c8e32fd70

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/SslHandler.java lines 1771–1983

    private final class SslTasksRunner implements Runnable {
        private final boolean inUnwrap;
        private final Runnable runCompleteTask = new Runnable() {
            @Override
            public void run() {
                runComplete();
            }
        };

        SslTasksRunner(boolean inUnwrap) {
            this.inUnwrap = inUnwrap;
        }

        // Handle errors which happened during task processing.
        private void taskError(Throwable e) {
            if (inUnwrap) {
                // As the error happened while the task was scheduled as part of unwrap(...) we also need to ensure
                // we fire it through the pipeline as inbound error to be consistent with what we do in decode(...).
                //
                // This will also ensure we fail the handshake future and flush all produced data.
                try {
                    handleUnwrapThrowable(ctx, e);
                } catch (Throwable cause) {
                    safeExceptionCaught(cause);
                }
            } else {
                setHandshakeFailure(ctx, e);
                forceFlush(ctx);
            }
        }

        // Try to call exceptionCaught(...)
        private void safeExceptionCaught(Throwable cause) {
            try {
                exceptionCaught(ctx, wrapIfNeeded(cause));
            } catch (Throwable error) {
                ctx.fireExceptionCaught(error);
            }
        }

        private Throwable wrapIfNeeded(Throwable cause) {
            if (!inUnwrap) {
                // If we are not in unwrap(...) we can just rethrow without wrapping at all.
                return cause;
            }
            // As the exception would have been triggered by an inbound operation we will need to wrap it in a
            // DecoderException to mimic what a decoder would do when decode(...) throws.
            return cause instanceof DecoderException ? cause : new DecoderException(cause);
        }

        private void tryDecodeAgain() {
            try {
                channelRead(ctx, Unpooled.EMPTY_BUFFER);
            } catch (Throwable cause) {
                safeExceptionCaught(cause);
            } finally {
                // As we called channelRead(...) we also need to call channelReadComplete(...) which
                // will ensure we either call ctx.fireChannelReadComplete() or will trigger a ctx.read() if
                // more data is needed.
                channelReadComplete0(ctx);
            }
        }

        /**
         * Executed after the wrapped {@code task} was executed via {@code delegatedTaskExecutor} to resume work
         * on the {@link EventExecutor}.
         */
        private void resumeOnEventExecutor() {
            assert ctx.executor().inEventLoop();
            clearState(STATE_PROCESS_TASK);
            try {
                HandshakeStatus status = engine.getHandshakeStatus();
                switch (status) {
                    // There is another task that needs to be executed and offloaded to the delegatingTaskExecutor as
                    // a result of this. Let's reschedule....
                    case NEED_TASK:
                        executeDelegatedTask(this);

                        break;

                    // The handshake finished, lets notify about the completion of it and resume processing.

Frequently Asked Questions

What is the SslTasksRunner class?
SslTasksRunner is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java.
Where is SslTasksRunner defined?
SslTasksRunner is defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java at line 1771.

Analyze Your Own Codebase

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

Try Supermodel Free