Skip to content

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

Merged
chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-brotli-maxAlloc
Jul 23, 2026
Merged

chrisvest merged 1 commit into
netty:5.0from
chrisvest:5.0-brotli-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 added this to the 5.0.0.Final milestone Jul 22, 2026
@chrisvest
chrisvest enabled auto-merge (squash) July 22, 2026 23:19
@chrisvest
chrisvest merged commit b975129 into netty:5.0 Jul 23, 2026
12 of 13 checks passed
@chrisvest
chrisvest deleted the 5.0-brotli-maxAlloc branch July 23, 2026 16:12
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