GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Codec-compression: Add zlib decompressors by yawkat · Pull Request #17155 · netty/netty

Codec-compression: Add zlib decompressors #17155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
chrisvest merged 25 commits into 4.2 from extract-zlib-decompressors
Jul 28, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Codec-compression: Add zlib decompressors #17155

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5737cd5
Codec-compression: Add zlib decompressor base
yawkat Jul 27, 2026
731fa0b
Codec-compression: Add JZlib decompressor
yawkat Jul 27, 2026
5b23fd4
Codec-compression: Add JDK zlib decompressor
yawkat Jul 27, 2026
fb6b4d6
ZlibCodecFactory: Add decompressor builder
yawkat Jul 27, 2026
1c8a165
JZlibDecompressor: Restore parent PR implementation
yawkat Jul 27, 2026
faa1113
JdkZlibDecompressor: Restore parent PR implementation
yawkat Jul 27, 2026
238f04d
ZlibDecompressor: Restore parent PR implementation
yawkat Jul 27, 2026
29321f0
JdkZlibDecompressor: Fix GZIP FEXTRA handling
yawkat Jul 27, 2026
0685084
JdkZlibDecompressor: Report complete after GZIP footer
yawkat Jul 27, 2026
754c82e
JZlibDecompressor: Release output on failure
yawkat Jul 27, 2026
d0af116
JdkZlibDecompressor: Release inflater on close
yawkat Jul 27, 2026
517d309
ZlibDecompressor: Reject negative max allocation
yawkat Jul 27, 2026
58fcb85
JZlibDecompressor: Reject truncated input
yawkat Jul 27, 2026
1ac2e09
JdkZlibDecompressor: Reject truncated input
yawkat Jul 27, 2026
3fe084a
JdkZlibDecompressor: Release output on failure
yawkat Jul 27, 2026
31a58ca
JZlibDecompressor: Release inflater on close
yawkat Jul 27, 2026
6a980a6
JdkZlibDecompressor: Validate GZIP magic
yawkat Jul 27, 2026
b6029da
JZlibDecompressorTest: Use try-with-resources
yawkat Jul 27, 2026
80a44f1
JZlibDecompressor: Simplify inflater lifecycle
yawkat Jul 27, 2026
732cf87
JZlibDecompressorTest: Cover direct input across outputs
yawkat Jul 27, 2026
cc1cc0c
JdkZlibDecompressor: Fix dictionary error message
yawkat Jul 27, 2026
b50e971
ZlibCodecFactory: Mark decompressor APIs unstable
yawkat Jul 27, 2026
914dfb7
ZlibCodecFactory: Remove decompressor builder
yawkat Jul 28, 2026
86a0db0
Codec-compression: Remove JZlib decompressor
yawkat Jul 28, 2026
553478f
JdkZlibDecompressor: Inline zlib decompressor base
yawkat Jul 28, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
JZlibDecompressor: Release inflater on close
Co-Authored-By: multicode <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@yawkat @multicode-agent
yawkat and multicode-agent committed Jul 27, 2026
commit 31a58ca96e7701becf6cb1692aeffcb236b9d4f4

There are no files selected for viewing

21 changes: 20 additions & 1 deletion 21 codec-compression/src/main/java/io/netty/handler/codec/compression/JZlibDecompressor.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class JZlibDecompressor extends ZlibDecompressor {
private final Inflater z = new Inflater();
Comment thread
yawkat marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

private boolean finished;
private boolean inputBufferInInflater;
private boolean inflaterEnded;
Comment thread
yawkat marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


JZlibDecompressor(Builder builder, ByteBufAllocator allocator) {
super(builder, allocator);
Expand Down Expand Up @@ -114,7 +115,7 @@ ByteBuf processOutput(ByteBuf buf) throws DecompressionException {
break;
case JZlib.Z_STREAM_END:
finished = true; // Do not decode anymore.
z.inflateEnd();
endInflater();
break;
case JZlib.Z_OK:
case JZlib.Z_BUF_ERROR:
Expand All @@ -136,6 +137,24 @@ ByteBuf processOutput(ByteBuf buf) throws DecompressionException {
}
}

private void endInflater() {
if (!inflaterEnded) {
inflaterEnded = true;
z.inflateEnd();
}
}

@Override
public void close() {
try {
super.close();
} finally {
endInflater();
z.next_in = null;
z.next_out = null;
}
}

@UnstableApi
public static Builder builder() {
return new Builder();
Expand Down
10 changes: 10 additions & 0 deletions 10 ...c-compression/src/test/java/io/netty/handler/codec/compression/JZlibDecompressorTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Arrays;
import java.util.zip.DeflaterOutputStream;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -75,6 +76,15 @@ public void testTruncatedInputRejectedAtEndOfInput() throws Exception {
}
}

@Test
public void testCloseBeforeCompletionIsIdempotent() {
Decompressor decompressor = JZlibDecompressor.builder().build(ByteBufAllocator.DEFAULT);
assertEquals(Decompressor.Status.NEED_INPUT, decompressor.status());
decompressor.addInput(Unpooled.wrappedBuffer(new byte[] { 0x78 }));
assertDoesNotThrow(decompressor::close);
assertDoesNotThrow(decompressor::close);
}

private static byte[] deflate(byte[] data) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
DeflaterOutputStream deflater = new DeflaterOutputStream(output);
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.