From 1b4c0f3345086fc867036ab9b0df4f1b004c362b Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Thu, 28 Mar 2024 14:50:33 +0100 Subject: [PATCH] Add a Netty substitution for ZstdConstants --- .../netty/deployment/NettyProcessor.java | 1 + .../HttpContentCompressorSubstitutions.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java index bb5370075c04c2..a7d5ae3e2c2a5a 100644 --- a/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java +++ b/extensions/netty/deployment/src/main/java/io/quarkus/netty/deployment/NettyProcessor.java @@ -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"); diff --git a/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/graal/HttpContentCompressorSubstitutions.java b/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/graal/HttpContentCompressorSubstitutions.java index baeb441687e800..2f2b360db19f6b 100644 --- a/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/graal/HttpContentCompressorSubstitutions.java +++ b/extensions/netty/runtime/src/main/java/io/quarkus/netty/runtime/graal/HttpContentCompressorSubstitutions.java @@ -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 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;