Skip to content

Commit

Permalink
Add a Netty substitution for ZstdConstants
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Mar 28, 2024
1 parent 6d6165c commit 1b4c0f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ NativeImageConfigBuildItem build(
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.extensions.compression.DeflateDecoder")
.addRuntimeInitializedClass("io.netty.handler.codec.http.websocketx.WebSocket00FrameEncoder")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.ZstdOptions")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.ZstdConstants")
.addRuntimeInitializedClass("io.netty.handler.codec.compression.BrotliOptions");
} else {
log.debug("Not registering Netty HTTP classes as they were not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public void flush(final ChannelHandlerContext ctx) {
}
}

@Substitute
@TargetClass(className = "io.netty.handler.codec.compression.ZstdConstants", onlyWith = IsZstdAbsent.class)
public static final class ZstdConstants {

// The constants make <clinit> calls to com.github.luben.zstd.Zstd so we cut links with that substitution.

static final int DEFAULT_COMPRESSION_LEVEL = 0;

static final int MIN_COMPRESSION_LEVEL = 0;

static final int MAX_COMPRESSION_LEVEL = 0;

static final int MAX_BLOCK_SIZE = 0;

static final int DEFAULT_BLOCK_SIZE = 0;
}

public static class IsZstdAbsent implements BooleanSupplier {

private boolean zstdAbsent;
Expand Down

0 comments on commit 1b4c0f3

Please sign in to comment.