Home / Function/ decodeJdkCompatible() — netty Function Reference

decodeJdkCompatible() — netty Function Reference

Architecture documentation for the decodeJdkCompatible() function in SslHandler.java from the netty codebase.

Function java Buffer Allocators calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  eb5ae59b_9b70_8065_9fe5_48f1bb487718["decodeJdkCompatible()"]
  d8b07a7c_44f8_c4e9_efe8_49bfae7d4af1["SslHandler"]
  eb5ae59b_9b70_8065_9fe5_48f1bb487718 -->|defined in| d8b07a7c_44f8_c4e9_efe8_49bfae7d4af1
  6aaf84ff_874c_1428_d191_d32a98e4c16e["decode()"]
  6aaf84ff_874c_1428_d191_d32a98e4c16e -->|calls| eb5ae59b_9b70_8065_9fe5_48f1bb487718
  04c08bc3_3cb7_7c02_dac5_71e493257fd0["exceptionCaught()"]
  eb5ae59b_9b70_8065_9fe5_48f1bb487718 -->|calls| 04c08bc3_3cb7_7c02_dac5_71e493257fd0
  23ca304b_58b0_41b7_c5ca_0810728d5ede["setHandshakeFailure()"]
  eb5ae59b_9b70_8065_9fe5_48f1bb487718 -->|calls| 23ca304b_58b0_41b7_c5ca_0810728d5ede
  51b61e7d_0f6d_53c7_ed6a_56a55b2ed5a7["unwrap()"]
  eb5ae59b_9b70_8065_9fe5_48f1bb487718 -->|calls| 51b61e7d_0f6d_53c7_ed6a_56a55b2ed5a7
  1807eec1_6f0b_edf4_8d02_a6d15d3c18c1["handleUnwrapThrowable()"]
  eb5ae59b_9b70_8065_9fe5_48f1bb487718 -->|calls| 1807eec1_6f0b_edf4_8d02_a6d15d3c18c1
  style eb5ae59b_9b70_8065_9fe5_48f1bb487718 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/ssl/SslHandler.java lines 1352–1402

    private void decodeJdkCompatible(ChannelHandlerContext ctx, ByteBuf in) throws NotSslRecordException {
        int packetLength = this.packetLength;
        // If we calculated the length of the current SSL record before, use that information.
        if (packetLength > 0) {
            if (in.readableBytes() < packetLength) {
                return;
            }
        } else {
            // Get the packet length and wait until we get a packets worth of data to unwrap.
            final int readableBytes = in.readableBytes();
            if (readableBytes < SslUtils.SSL_RECORD_HEADER_LENGTH) {
                return;
            }
            packetLength = getEncryptedPacketLength(in, in.readerIndex(), true);
            if (packetLength == SslUtils.NOT_ENCRYPTED) {
                // Not an SSL/TLS packet
                NotSslRecordException e = new NotSslRecordException(
                        "not an SSL/TLS record: " + ByteBufUtil.hexDump(in));
                in.skipBytes(in.readableBytes());

                // First fail the handshake promise as we may need to have access to the SSLEngine which may
                // be released because the user will remove the SslHandler in an exceptionCaught(...) implementation.
                setHandshakeFailure(ctx, e);

                throw e;
            }
            if (packetLength == NOT_ENOUGH_DATA) {
                return;
            }
            assert packetLength > 0;
            if (packetLength > readableBytes) {
                // wait until the whole packet can be read
                this.packetLength = packetLength;
                return;
            }
        }

        // Reset the state of this class so we can get the length of the next packet. We assume the entire packet will
        // be consumed by the SSLEngine.
        this.packetLength = 0;
        try {
            final int bytesConsumed = unwrap(ctx, in, packetLength);
            if (bytesConsumed != packetLength && !engine.isInboundDone()) {
                // The JDK equivalent of getEncryptedPacketLength has some optimizations and can behave slightly
                // differently to ours, but this should always be a sign of bad input data.
                throw new NotSslRecordException();
            }
        } catch (Throwable cause) {
            handleUnwrapThrowable(ctx, cause);
        }
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does decodeJdkCompatible() do?
decodeJdkCompatible() is a function in the netty codebase, defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java.
Where is decodeJdkCompatible() defined?
decodeJdkCompatible() is defined in handler/src/main/java/io/netty/handler/ssl/SslHandler.java at line 1352.
What does decodeJdkCompatible() call?
decodeJdkCompatible() calls 4 function(s): exceptionCaught, handleUnwrapThrowable, setHandshakeFailure, unwrap.
What calls decodeJdkCompatible()?
decodeJdkCompatible() is called by 1 function(s): decode.

Analyze Your Own Codebase

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

Try Supermodel Free