Home / Function/ Object() — netty Function Reference

Object() — netty Function Reference

Architecture documentation for the Object() function in LengthFieldBasedFrameDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  f122928e_f2b2_90a0_b78d_5ee053f14758["Object()"]
  687df7d8_4057_fca4_6694_3143553abf69["LengthFieldBasedFrameDecoder"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|defined in| 687df7d8_4057_fca4_6694_3143553abf69
  9f9e29d6_6751_0f27_80ee_3be809f035b2["decode()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| 9f9e29d6_6751_0f27_80ee_3be809f035b2
  eccb157b_d7cc_e4ef_8e1a_92c29ab6d4cd["discardingTooLongFrame()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| eccb157b_d7cc_e4ef_8e1a_92c29ab6d4cd
  4bacf009_3a37_156a_47bf_7115c7075810["getUnadjustedFrameLength()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| 4bacf009_3a37_156a_47bf_7115c7075810
  f6ba9ada_525e_59d1_6bae_ee1cf2fcdbc1["failOnNegativeLengthField()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| f6ba9ada_525e_59d1_6bae_ee1cf2fcdbc1
  5bfbea73_f4e3_51f7_a58c_8e17cd79f25e["failOnFrameLengthLessThanLengthFieldEndOffset()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| 5bfbea73_f4e3_51f7_a58c_8e17cd79f25e
  afaf5979_a43d_e80f_807f_08d92b1bd469["exceededFrameLength()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| afaf5979_a43d_e80f_807f_08d92b1bd469
  53ffab28_8315_e224_a761_791b1d83f641["failOnFrameLengthLessThanInitialBytesToStrip()"]
  f122928e_f2b2_90a0_b78d_5ee053f14758 -->|calls| 53ffab28_8315_e224_a761_791b1d83f641
  style f122928e_f2b2_90a0_b78d_5ee053f14758 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java lines 397–444

    protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
        long frameLength = 0;
        if (frameLengthInt == -1) { // new frame

            if (discardingTooLongFrame) {
                discardingTooLongFrame(in);
            }

            if (in.readableBytes() < lengthFieldEndOffset) {
                return null;
            }

            int actualLengthFieldOffset = in.readerIndex() + lengthFieldOffset;
            frameLength = getUnadjustedFrameLength(in, actualLengthFieldOffset, lengthFieldLength, byteOrder);

            if (frameLength < 0) {
                failOnNegativeLengthField(in, frameLength, lengthFieldEndOffset);
            }

            frameLength += lengthAdjustment + lengthFieldEndOffset;

            if (frameLength < lengthFieldEndOffset) {
                failOnFrameLengthLessThanLengthFieldEndOffset(in, frameLength, lengthFieldEndOffset);
            }

            if (frameLength > maxFrameLength) {
                exceededFrameLength(in, frameLength);
                return null;
            }
            // never overflows because it's less than maxFrameLength
            frameLengthInt = (int) frameLength;
        }
        if (in.readableBytes() < frameLengthInt) { // frameLengthInt exist , just check buf
            return null;
        }
        if (initialBytesToStrip > frameLengthInt) {
            failOnFrameLengthLessThanInitialBytesToStrip(in, frameLength, initialBytesToStrip);
        }
        in.skipBytes(initialBytesToStrip);

        // extract frame
        int readerIndex = in.readerIndex();
        int actualFrameLength = frameLengthInt - initialBytesToStrip;
        ByteBuf frame = extractFrame(ctx, in, readerIndex, actualFrameLength);
        in.readerIndex(readerIndex + actualFrameLength);
        frameLengthInt = -1; // start processing the next frame
        return frame;
    }

Domain

Subdomains

Frequently Asked Questions

What does Object() do?
Object() is a function in the netty codebase, defined in codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java.
Where is Object() defined?
Object() is defined in codec-base/src/main/java/io/netty/handler/codec/LengthFieldBasedFrameDecoder.java at line 397.
What does Object() call?
Object() calls 7 function(s): decode, discardingTooLongFrame, exceededFrameLength, failOnFrameLengthLessThanInitialBytesToStrip, failOnFrameLengthLessThanLengthFieldEndOffset, failOnNegativeLengthField, getUnadjustedFrameLength.

Analyze Your Own Codebase

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

Try Supermodel Free