Skip to content

Fix maxAllocation for brotli-encoded content in HttpContentDecompress… - #17124

Merged
chrisvest merged 2 commits into
netty:4.1from
chrisvest:4.1-botli-maxalloc
Jul 24, 2026
Merged

chrisvest merged 2 commits into
netty:4.1from
chrisvest:4.1-botli-maxalloc

Conversation

@chrisvest

Copy link
Copy Markdown
Member

…or (#17037)

Motivation
HttpContentDecompressor documents maxAllocation as the maximum decompression buffer size. For gzip / deflate / zstd it is routed to each decoder's output-cap parameter. For brotli it was passed to new BrotliDecoder(maxAllocation), whose single argument is inputBufferSize, not the output cap. So a large maxAllocation enlarged brotli's input buffer while the output cap stayed at the 64 KiB default; a small maxAllocation did not tighten the output cap for brotli at all. Modifications
Add BrotliDecoder.newDecoderWithMaxAllocation(int): routes maxAllocation to outputBufferSize, 0 falls back to new BrotliDecoder(). HttpContentDecompressor: brotli branch uses the new factory instead of new BrotliDecoder(maxAllocation).
Add
HttpContentDecompressorTest#testBrotliDecodingHonorsMaxAllocationAsOutputCap: brotli-compress 128 KiB, decode with HttpContentDecompressor(64), assert lossless decode and >100 chunks.
Result
Fixes #17034.
maxAllocation now has consistent semantics across gzip / deflate / zstd / brotli. No API removed, one new public factory added on BrotliDecoder.


Co-authored-by: Norman Maurer [email protected]

(cherry picked from commit 0332676)

…or (netty#17037)

Motivation
HttpContentDecompressor documents maxAllocation as the maximum
decompression buffer size. For gzip / deflate / zstd it is routed to
each decoder's output-cap parameter. For brotli it was passed to new
BrotliDecoder(maxAllocation), whose single argument is inputBufferSize,
not the output cap. So a large maxAllocation enlarged brotli's input
buffer while the output cap stayed at the 64 KiB default; a small
maxAllocation did not tighten the output cap for brotli at all.
Modifications
Add BrotliDecoder.newDecoderWithMaxAllocation(int): routes maxAllocation
to outputBufferSize, 0 falls back to new BrotliDecoder().
`HttpContentDecompressor`: brotli branch uses the new factory instead of
new BrotliDecoder(maxAllocation).
Add
HttpContentDecompressorTest#testBrotliDecodingHonorsMaxAllocationAsOutputCap:
brotli-compress 128 KiB, decode with HttpContentDecompressor(64), assert
lossless decode and >100 chunks.
Result
Fixes netty#17034.
maxAllocation now has consistent semantics across gzip / deflate / zstd
/ brotli. No API removed, one new public factory added on BrotliDecoder.

---------

Co-authored-by: Norman Maurer <[email protected]>

(cherry picked from commit 0332676)
@chrisvest
chrisvest merged commit ac9ec25 into netty:4.1 Jul 24, 2026
18 checks passed
@chrisvest
chrisvest deleted the 4.1-botli-maxalloc branch July 24, 2026 20:11
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
netty#17124)

…or (netty#17037)

Motivation
HttpContentDecompressor documents maxAllocation as the maximum
decompression buffer size. For gzip / deflate / zstd it is routed to
each decoder's output-cap parameter. For brotli it was passed to new
BrotliDecoder(maxAllocation), whose single argument is inputBufferSize,
not the output cap. So a large maxAllocation enlarged brotli's input
buffer while the output cap stayed at the 64 KiB default; a small
maxAllocation did not tighten the output cap for brotli at all.
Modifications
Add BrotliDecoder.newDecoderWithMaxAllocation(int): routes maxAllocation
to outputBufferSize, 0 falls back to new BrotliDecoder().
`HttpContentDecompressor`: brotli branch uses the new factory instead of
new BrotliDecoder(maxAllocation).
Add

HttpContentDecompressorTest#testBrotliDecodingHonorsMaxAllocationAsOutputCap:
brotli-compress 128 KiB, decode with HttpContentDecompressor(64), assert
lossless decode and >100 chunks.
Result
Fixes netty#17034.
maxAllocation now has consistent semantics across gzip / deflate / zstd
/ brotli. No API removed, one new public factory added on BrotliDecoder.

---------

Co-authored-by: Norman Maurer <[email protected]>

(cherry picked from commit 0332676)

Co-authored-by: skyguard1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants