Skip to content

Codec-compression: Add Zstd decompressor - #17152

Merged
chrisvest merged 4 commits into
4.2from
extract-zstd-decompressor-16743
Jul 28, 2026
Merged

Codec-compression: Add Zstd decompressor#17152
chrisvest merged 4 commits into
4.2from
extract-zstd-decompressor-16743

Conversation

@yawkat

@yawkat yawkat commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Motivation:

The decompressor API migration tracked in #16743 is being split out from #15667 into smaller, reviewable pieces. This adds the Zstd decompressor slice on top of the core decompressor API that is already present, including the ZstdDecoder window-memory guard added in #16850.

Modification:

Add ZstdDecompressor, backed by zstd-jni ZstdInputStreamNoFinalizer, and add the matching AbstractDecompressorTest coverage using ZstdEncoder.

The decompressor builder exposes maxWindowLog(int) and applies it through ZstdInputStreamNoFinalizer.setLongMax(...) so frames declaring oversized windows are rejected before zstd allocates excessive native memory. takeOutput() also uses the shared compression forward-size as its per-call output chunk size.

Result:

Zstd now has a decompressor implementation for the new API with focused contract coverage and bounded zstd native window memory by default.

Verification:

  • ./mvnw -pl codec-compression -am -DskipRemoteStaging=true -Dcheckstyle.skip=false -DskipTests=false -Dtest=ZstdDecompressorTest -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -pl codec-compression -am -DskipRemoteStaging=true -Dcheckstyle.skip=false -DskipTests=false verify

Part of #16743.

yawkat and others added 2 commits July 27, 2026 13:23
Extract the Zstd decompressor from the decompressor API draft and add the matching contract test.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

Co-Authored-By: multicode <multicode@yawk.at>
Port the ZstdDecoder maxWindowLog guard to the decompressor API and use the shared forward-size for output chunks.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

Co-Authored-By: multicode <multicode@yawk.at>
@yawkat
yawkat marked this pull request as ready for review July 27, 2026 14:01
@yawkat
yawkat requested a review from Copilot July 27, 2026 14:01
@yawkat yawkat added the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Jul 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Zstandard (Zstd) support to Netty’s new Decompressor API as part of the decompressor migration tracked in #16743, including contract tests and a guard to cap Zstd window memory usage via setLongMax(...).

Changes:

  • Introduces ZstdDecompressor backed by zstd-jni’s ZstdInputStreamNoFinalizer, including a maxWindowLog(int) builder option.
  • Adds ZstdDecompressorTest extending the shared AbstractDecompressorTest contract suite and adds focused coverage for rejecting oversized Window_Log.
  • Uses the shared CompressionUtil.DEFAULT_MAX_FORWARD_BYTES as the per-call output chunk size in takeOutput().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
codec-compression/src/main/java/io/netty/handler/codec/compression/ZstdDecompressor.java New Zstd implementation of the Decompressor API with configurable window-log cap and streaming output.
codec-compression/src/test/java/io/netty/handler/codec/compression/ZstdDecompressorTest.java Adds contract coverage plus specific tests for maxWindowLog rejection/acceptance behavior using ZstdEncoder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fail fast when zstd-jni is unavailable and release empty Zstd decompressor input immediately.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

Co-Authored-By: multicode <multicode@yawk.at>

@chrisvest chrisvest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some comments.

Clean up the Zstd stream if configuration fails and force the final zstd read on end-of-input so truncated frames are reported.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

Co-Authored-By: multicode <multicode@yawk.at>
@testlens-app

testlens-app Bot commented Jul 28, 2026

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / macos-aarch64-java11-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo) 5% 🟠

🏷️ Commit: 1310ac9
▶️ Tests: 33099 executed
⚪️ Checks: 19/19 completed

Test Failures

KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-aarch64-java11-boringssl build)
org.opentest4j.AssertionFailedError
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect0(DatagramUnicastTest.java:414)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:375)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:210)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$7.run(DatagramUnicastTest.java:204)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$7.run(DatagramUnicastTest.java:201)
	at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:201)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)

Muted Tests

Select tests to mute in this pull request:

  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo)

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app.

@chrisvest
chrisvest merged commit a4e5641 into 4.2 Jul 28, 2026
19 of 20 checks passed
@chrisvest
chrisvest deleted the extract-zstd-decompressor-16743 branch July 28, 2026 18:33
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17168

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Jul 28, 2026
normanmaurer pushed a commit that referenced this pull request Aug 4, 2026
Auto-port of #17152 to 5.0
Cherry-picked commit: a4e5641

---
Motivation:

The decompressor API migration tracked in #16743 is being split out from
#15667 into smaller, reviewable pieces. This adds the Zstd decompressor
slice on top of the core decompressor API that is already present,
including the ZstdDecoder window-memory guard added in #16850.

Modification:

Add `ZstdDecompressor`, backed by zstd-jni `ZstdInputStreamNoFinalizer`,
and add the matching `AbstractDecompressorTest` coverage using
`ZstdEncoder`.

The decompressor builder exposes `maxWindowLog(int)` and applies it
through `ZstdInputStreamNoFinalizer.setLongMax(...)` so frames declaring
oversized windows are rejected before zstd allocates excessive native
memory. `takeOutput()` also uses the shared compression forward-size as
its per-call output chunk size.

Result:

Zstd now has a decompressor implementation for the new API with focused
contract coverage and bounded zstd native window memory by default.

Verification:

- `./mvnw -pl codec-compression -am -DskipRemoteStaging=true
-Dcheckstyle.skip=false -DskipTests=false -Dtest=ZstdDecompressorTest
-Dsurefire.failIfNoSpecifiedTests=false test`
- `./mvnw -pl codec-compression -am -DskipRemoteStaging=true
-Dcheckstyle.skip=false -DskipTests=false verify`

Part of #16743.

Co-authored-by: Jonas Konrad <jonas.konrad@oracle.com>
Co-authored-by: multicode <multicode@yawk.at>
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.

4 participants