Skip to content

Drop the fallback for Netty before 4.2.17 - #2396

Merged
hyperxpro merged 2 commits into
AsyncHttpClient:mainfrom
mkurz:cleanup/decompressor-api-fallback
Nov 21, 2026
Merged

hyperxpro merged 2 commits into
AsyncHttpClient:mainfrom
mkurz:cleanup/decompressor-api-fallback

Conversation

@mkurz

@mkurz mkurz commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Since fix(netty): stop inflating a suspended HTTP/1.1 response #2362, AHC decompresses HTTP/1.1 br, zstd and snappy bodies with Netty's pull-based Decompressor API, so that they wait for demand. Netty added that API in 4.2.17. With an older Netty, Http1ContentDecompressor caught the LinkageError and left these codings to HttpContentDecompressor, which decompresses them as soon as they are read.
  • AHC declares a Netty that has the API (4.2.20 on main, 4.2.21 with Upgrade Netty to 4.2.21.Final #2395), so this PR drops that fallback. The README now says that AHC needs Netty 4.2.17 or later.

Change

  • Http1ContentDecompressor: the pullAvailable flag and the LinkageError catch go. newPullDecompression now only creates the PullDecompression.
  • Unchanged:
    • PullDecompression.create still checks whether Brotli and zstd are available, since brotli4j and zstd-jni are optional dependencies. A body whose library is missing is still left undecoded, as HttpContentDecompressor does.
    • The size limit and the split into parts of at most 64 KiB are unchanged.
  • Test: gzipAndDeflateDoNotNeedNettysDecompressorApi goes, together with the class loader that hid the API from it, as an older Netty would.
  • Docs: the README, the Javadoc of ResponseBodyControl.suspend() and the class Javadoc of Http1ContentDecompressor and PullDecompression no longer describe the fallback. The README now says that AHC needs Netty 4.2.17 or later, as it uses the API Netty added there, and that on-demand decompression applies over HTTP/1.1, and its paragraph on truncated bodies no longer names Brotli and Snappy bodies decompressed as soon as they are read. PullDecompression still notes that Netty marks the API @UnstableApi, so a Netty upgrade may require changes there.

Notes

  • With AHC's declared Netty dependency, the fallback for older Netty versions is unnecessary. With Netty older than 4.2.17, br, zstd and snappy responses now fail instead of being decompressed as soon as they are read.
  • This PR and Upgrade Netty to 4.2.21.Final #2395 rewrite the same sentences in the README, the Javadoc of ResponseBodyControl.suspend() and the class Javadoc of Http1ContentDecompressor. Upgrade Netty to 4.2.21.Final #2395 removes the exception for zstd at a non-positive io.netty.compression.defaultMaxForwardBytes, which this PR keeps. Whichever is merged second, I'll merge main into it and resolve that.

AI disclosure

Claude Code on behalf of Matthias Kurz. The commit includes Co-Authored-By per AGENTS.md.

Test plan

  • ./mvnw -B -ntp -Dgpg.skip=true clean verify on JDK 11: 2,097 tests, 0 failures, 0 errors, 11 skipped; Revapi passed. No test-skipping flags were used. That is one test fewer than on main: the removed class loader test.
  • The Http1ContentDecompressor*Test, Http2ContentDecompressorTest, Http1Decompression*Test and ResponseBodyControlTest classes: 141 tests, 0 failures.
  • With the README change from review (82fde4d68), the same clean verify: 2,097 tests, 0 failures, 0 errors, 22 skipped; Revapi passed. Docker was not running, so the 11 Testcontainers proxy tests skipped themselves; they ran and passed with 32bb77670 (2,097 tests, 11 skipped).
  • Merges with Wait for demand after the server closes #2394 without conflicts.
  • With -Dnetty.version=4.2.17.Final, all client tests (./mvnw -pl client clean test, JDK 11): 2,097 tests, 2 failures, both in tests that compare AHC's output and read requests with Netty's own decoders, which changed after 4.2.17 (decodesLikeNettyForEveryBodyAndSplit, requestsReadsLikeNettyWhenAutoReadIsOff).

Without Netty's pull-based Decompressor API, which Netty added in
4.2.17, Http1ContentDecompressor left br, zstd and snappy to
HttpContentDecompressor, which decompresses them as soon as they are
read. AHC declares a newer Netty, so the fallback goes, and with it
the test that hid the API with a class loader.

PullDecompression still checks whether Brotli and zstd are available,
since brotli4j and zstd-jni are optional: a body whose library is
missing is still left undecoded, as HttpContentDecompressor does.

The README and the Javadoc no longer describe the fallback.

Claude Code on behalf of Matthias Kurz

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With Netty older than 4.2.17, br, zstd and snappy responses now fail
instead of being decompressed as soon as they are read. Say in the
README that AHC needs Netty 4.2.17 or later.

Claude Code on behalf of Matthias Kurz

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mkurz
mkurz requested a review from hyperxpro November 20, 2026 23:34
@hyperxpro
hyperxpro merged commit abc6846 into AsyncHttpClient:main Nov 21, 2026
13 checks passed
mkurz added a commit to mkurz/async-http-client that referenced this pull request Nov 21, 2026
Brings in AsyncHttpClient#2396, which conflicts with this branch in the README, the
Javadoc of ResponseBodyControl.suspend() and the class Javadoc of
Http1ContentDecompressor, and AsyncHttpClient#2394, which changed the same files.

The resolution keeps the Netty 4.2.17 requirement from AsyncHttpClient#2396 and the
note on Netty 4.2.21 from this branch. As this branch no longer sends
zstd to HttpContentDecompressor, it also drops the clause on Zstd
bodies decompressed as soon as they are read from the README's
paragraph on truncated bodies, which merged without a conflict.

Claude Code on behalf of Matthias Kurz

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mkurz
mkurz deleted the cleanup/decompressor-api-fallback branch November 21, 2026 08:30
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