Home / Function/ Object() — netty Function Reference

Object() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  abfd070d_4226_1951_b9b5_41207235cf3b["Object()"]
  7590eb23_fb43_56c3_4de3_56dbec1f1149["DelimiterBasedFrameDecoder"]
  abfd070d_4226_1951_b9b5_41207235cf3b -->|defined in| 7590eb23_fb43_56c3_4de3_56dbec1f1149
  e196054f_18fc_682e_e17c_e0c7cd46549a["decode()"]
  abfd070d_4226_1951_b9b5_41207235cf3b -->|calls| e196054f_18fc_682e_e17c_e0c7cd46549a
  9455cfd7_2bf3_7b75_5247_f6002d1686f5["indexOf()"]
  abfd070d_4226_1951_b9b5_41207235cf3b -->|calls| 9455cfd7_2bf3_7b75_5247_f6002d1686f5
  2cb47d94_14e0_d6f2_0b0b_3fa3f6e3726b["fail()"]
  abfd070d_4226_1951_b9b5_41207235cf3b -->|calls| 2cb47d94_14e0_d6f2_0b0b_3fa3f6e3726b
  style abfd070d_4226_1951_b9b5_41207235cf3b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-base/src/main/java/io/netty/handler/codec/DelimiterBasedFrameDecoder.java lines 229–295

    protected Object decode(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception {
        if (lineBasedDecoder != null) {
            return lineBasedDecoder.decode(ctx, buffer);
        }
        // Try all delimiters and choose the delimiter which yields the shortest frame.
        int minFrameLength = Integer.MAX_VALUE;
        ByteBuf minDelim = null;
        for (ByteBuf delim: delimiters) {
            int frameLength = indexOf(buffer, delim);
            if (frameLength >= 0 && frameLength < minFrameLength) {
                minFrameLength = frameLength;
                minDelim = delim;
            }
        }

        if (minDelim != null) {
            int minDelimLength = minDelim.capacity();
            ByteBuf frame;

            if (discardingTooLongFrame) {
                // We've just finished discarding a very large frame.
                // Go back to the initial state.
                discardingTooLongFrame = false;
                buffer.skipBytes(minFrameLength + minDelimLength);

                int tooLongFrameLength = this.tooLongFrameLength;
                this.tooLongFrameLength = 0;
                if (!failFast) {
                    fail(tooLongFrameLength);
                }
                return null;
            }

            if (minFrameLength > maxFrameLength) {
                // Discard read frame.
                buffer.skipBytes(minFrameLength + minDelimLength);
                fail(minFrameLength);
                return null;
            }

            if (stripDelimiter) {
                frame = buffer.readRetainedSlice(minFrameLength);
                buffer.skipBytes(minDelimLength);
            } else {
                frame = buffer.readRetainedSlice(minFrameLength + minDelimLength);
            }

            return frame;
        } else {
            if (!discardingTooLongFrame) {
                if (buffer.readableBytes() > maxFrameLength) {
                    // Discard the content of the buffer until a delimiter is found.
                    tooLongFrameLength = buffer.readableBytes();
                    buffer.skipBytes(buffer.readableBytes());
                    discardingTooLongFrame = true;
                    if (failFast) {
                        fail(tooLongFrameLength);
                    }
                }
            } else {
                // Still discarding the buffer since a delimiter is not found.
                tooLongFrameLength += buffer.readableBytes();
                buffer.skipBytes(buffer.readableBytes());
            }
            return null;
        }
    }

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/DelimiterBasedFrameDecoder.java.
Where is Object() defined?
Object() is defined in codec-base/src/main/java/io/netty/handler/codec/DelimiterBasedFrameDecoder.java at line 229.
What does Object() call?
Object() calls 3 function(s): decode, fail, indexOf.

Analyze Your Own Codebase

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

Try Supermodel Free