Repository navigation
Port: Codec-compression: Add BrotliDecompressor - #17171
Conversation
Motivation: The decompressor API migration tracked in netty#16743 needs per-format implementations split into independently reviewable changes. Brotli support is one of the remaining formats after the core decompressor API landed in netty#16745. Modification: - Add `BrotliDecompressor` using the new `Decompressor` API. - Add `BrotliDecompressorTest` using the shared decompressor contract tests. - Fix `BrotliEncoder` close handling so the finish future returned during close is completed by the writer. Result: Brotli now has a reusable decompressor implementation that can be used without a channel-based decoder, and the codec-compression module verifies successfully. Part of netty#16743. --------- Co-authored-by: multicode <[email protected]> (cherry picked from commit b8fb58f)
|
@yawkat Had to redo the |
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds Brotli support to the new Decompressor API and aligns Brotli encoder shutdown semantics with the channel writer’s completion lifecycle.
Changes:
- Introduce
BrotliDecompressorimplementing the newDecompressorAPI (with a builder). - Add
BrotliDecompressorTestbased on the shared decompressor contract tests. - Fix
BrotliEncoderclose/finish handling so the close promise is completed by the writer.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliDecompressor.java | New reusable Brotli decompressor implementation using DecoderJNI.Wrapper. |
| codec-compression/src/test/java/io/netty/handler/codec/compression/BrotliDecompressorTest.java | Contract-style tests for Brotli decompression behavior and edge conditions. |
| codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliEncoder.java | Adjusts close/finish wiring so close completion is driven by the writer’s finish future. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private final ChannelHandlerContext ctx; | ||
| private final Promise<Void> closeFuture; | ||
| private boolean isClosed; |
| public void close() { | ||
| final Promise<Void> promise = ctx.newPromise(); | ||
|
|
||
| ctx.executor().execute(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| try { | ||
| finish(promise); | ||
| } catch (IOException ex) { | ||
| promise.setFailure(new IllegalStateException("Failed to finish encoding", ex)); | ||
| } | ||
| ctx.executor().execute(() -> { | ||
| try { | ||
| finish(closeFuture); | ||
| } catch (IOException ex) { | ||
| closeFuture.setFailure(new IllegalStateException("Failed to finish encoding", ex)); | ||
| } | ||
| }); | ||
| } |
Co-Authored-By: multicode <[email protected]>
|
fixed the same issue in #17175 |
|
Ok, I think this should pass now. |
✅ All tests passed ✅🏷️ Commit: edfc7c6 Learn more about TestLens at testlens.app. |
Motivation:
The decompressor API migration tracked in #16743 needs per-format
implementations split into independently reviewable changes. Brotli
support is one of the remaining formats after the core decompressor API
landed in #16745.
Modification:
BrotliDecompressorusing the newDecompressorAPI.BrotliDecompressorTestusing the shared decompressor contracttests.
BrotliEncoderclose handling so the finish future returnedduring close is completed by the writer.
Result:
Brotli now has a reusable decompressor implementation that can be used
without a channel-based decoder, and the codec-compression module
verifies successfully.
Part of #16743.
Co-authored-by: multicode [email protected]
(cherry picked from commit b8fb58f)