Home / Function/ ByteBuf() — netty Function Reference

ByteBuf() — netty Function Reference

Architecture documentation for the ByteBuf() function in ZlibDecoder.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d4e9d28c_64e9_4aca_f5d6_26754b244701["ByteBuf()"]
  c6c9a2c2_7ac0_219d_db9e_bb2f3577a8fa["ZlibDecoder"]
  d4e9d28c_64e9_4aca_f5d6_26754b244701 -->|defined in| c6c9a2c2_7ac0_219d_db9e_bb2f3577a8fa
  247b1bbd_6674_8b74_87db_807943f1eeb6["decompressionBufferExhausted()"]
  d4e9d28c_64e9_4aca_f5d6_26754b244701 -->|calls| 247b1bbd_6674_8b74_87db_807943f1eeb6
  style d4e9d28c_64e9_4aca_f5d6_26754b244701 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-compression/src/main/java/io/netty/handler/codec/compression/ZlibDecoder.java lines 62–84

    protected ByteBuf prepareDecompressBuffer(ChannelHandlerContext ctx, ByteBuf buffer, int preferredSize) {
        if (buffer == null) {
            if (maxAllocation == 0) {
                return ctx.alloc().heapBuffer(preferredSize);
            }

            return ctx.alloc().heapBuffer(Math.min(preferredSize, maxAllocation), maxAllocation);
        }

        // this always expands the buffer if possible, even if the expansion is less than preferredSize
        // we throw the exception only if the buffer could not be expanded at all
        // this means that one final attempt to deserialize will always be made with the buffer at maxAllocation
        if (buffer.ensureWritable(preferredSize, true) == 1) {
            // buffer must be consumed so subclasses don't add it to output
            // we therefore duplicate it when calling decompressionBufferExhausted() to guarantee non-interference
            // but wait until after to consume it so the subclass can tell how much output is really in the buffer
            decompressionBufferExhausted(buffer.duplicate());
            buffer.skipBytes(buffer.readableBytes());
            throw new DecompressionException("Decompression buffer has reached maximum size: " + buffer.maxCapacity());
        }

        return buffer;
    }

Domain

Subdomains

Frequently Asked Questions

What does ByteBuf() do?
ByteBuf() is a function in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/ZlibDecoder.java.
Where is ByteBuf() defined?
ByteBuf() is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/ZlibDecoder.java at line 62.
What does ByteBuf() call?
ByteBuf() calls 1 function(s): decompressionBufferExhausted.

Analyze Your Own Codebase

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

Try Supermodel Free