Skip to content

Auto-port 5.0: Fix ZstdDecoder and ZstdDecompressor with a non-positive defaultMaxForwardBytes - #18383

Merged
chrisvest merged 2 commits into
5.0from
auto-port-pr-18289-to-5.0
Nov 13, 2026
Merged

chrisvest merged 2 commits into
5.0from
auto-port-pr-18289-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #18289 to 5.0
Cherry-picked commit: 5baf6f3


Motivation:

Since #17896, ZstdDecoder sizes its output buffers as the smaller of maxForwardBytes and the frame content size. With a maximumAllocationSize of 0, which HttpContentDecompressor and DelegatingDecompressorFrameListener pass by default, maxForwardBytes is io.netty.compression.defaultMaxForwardBytes. When that property is set to 0, every output buffer has a capacity of 0, so nothing is decompressed and only empty buffers are forwarded: a zstd body comes out empty, without an error. Below 0, the allocation fails with initialCapacity : -1. Before #17896, both decoded the body.

Modification:

  • Size the output buffers from maxForwardBytes only when it is positive, and use 64 KiB, the property's default, otherwise. The forwarding threshold itself is unchanged.
  • Don't forward empty buffers, which a threshold of 0 or less also did before Don't size ZstdDecoder output buffers from the frame content size #17896, once the output was drained.
  • Add a package-private constructor that takes the default threshold, and a test that decodes a 1 MiB body with thresholds of 0 and -1.

Result:

ZstdDecoder decodes zstd bodies again when io.netty.compression.defaultMaxForwardBytes is 0 or negative, and the frame header still cannot drive the allocation size.

…rwardBytes (#18289)

Motivation:

Since #17896, `ZstdDecoder` sizes its output buffers as the smaller of
`maxForwardBytes` and the frame content size. With a
`maximumAllocationSize` of 0, which `HttpContentDecompressor` and
`DelegatingDecompressorFrameListener` pass by default, `maxForwardBytes`
is `io.netty.compression.defaultMaxForwardBytes`. When that property is
set to 0, every output buffer has a capacity of 0, so nothing is
decompressed and only empty buffers are forwarded: a zstd body comes out
empty, without an error. Below 0, the allocation fails with
`initialCapacity : -1`. Before #17896, both decoded the body.

Modification:

- Size the output buffers from `maxForwardBytes` only when it is
positive, and use 64 KiB, the property's default, otherwise. The
forwarding threshold itself is unchanged.
- Don't forward empty buffers, which a threshold of 0 or less also did
before #17896, once the output was drained.
- Add a package-private constructor that takes the default threshold,
and a test that decodes a 1 MiB body with thresholds of 0 and -1.

Result:

`ZstdDecoder` decodes zstd bodies again when
`io.netty.compression.defaultMaxForwardBytes` is 0 or negative, and the
frame header still cannot drive the allocation size.

(cherry picked from commit 5baf6f3)
@testlens-app

This comment has been minimized.

@chrisvest chrisvest added this to the 5.0.0.Final milestone Nov 13, 2026
@chrisvest
chrisvest enabled auto-merge (squash) November 13, 2026 18:06
@chrisvest
chrisvest merged commit b4b1074 into 5.0 Nov 13, 2026
19 of 21 checks passed
@chrisvest
chrisvest deleted the auto-port-pr-18289-to-5.0 branch November 13, 2026 19:51
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.

3 participants