From ab6b3b225da846fde2b33ce378768e428c5eab06 Mon Sep 17 00:00:00 2001 From: Athou Date: Thu, 15 Oct 2026 08:02:05 +0200 Subject: [PATCH] Revert "add support for zstd and brotli compression" because they use native libraries that need to be extracted in a temp folder which we want to avoid --- commafeed-server/pom.xml | 8 ------- .../com/commafeed/NativeImageClasses.java | 22 ++++++++++++++++++- .../commafeed/backend/HttpClientFactory.java | 4 ---- .../com/commafeed/backend/HttpGetterTest.java | 14 +----------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/commafeed-server/pom.xml b/commafeed-server/pom.xml index e81a8753..3d44caec 100644 --- a/commafeed-server/pom.xml +++ b/commafeed-server/pom.xml @@ -461,14 +461,6 @@ ayza-for-apache5 10.1.0 - - com.github.luben - zstd-jni - - - com.aayushatharva.brotli4j - brotli4j - com.github.seancfoley ipaddress diff --git a/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java b/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java index 9b5d3fff..bda41f0f 100644 --- a/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java +++ b/commafeed-server/src/main/java/com/commafeed/NativeImageClasses.java @@ -6,6 +6,8 @@ import com.codahale.metrics.Histogram; import com.codahale.metrics.Meter; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Timer; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; import io.quarkus.runtime.annotations.RegisterForReflection; @@ -346,4 +348,22 @@ import io.quarkus.runtime.annotations.RegisterForReflection; com.rometools.opml.feed.synd.impl.ConverterForOPML10.class, com.rometools.opml.feed.synd.impl.ConverterForOPML20.class, }) -public class NativeImageClasses {} +public class NativeImageClasses { + + // disable zstd and brotli runtime detection because it causes native image failure + @TargetClass(className = "org.apache.hc.client5.http.impl.ZstdRuntime") + static final class ZstdRuntime { + @Substitute + public static boolean available() { + return false; + } + } + + @TargetClass(className = "org.apache.hc.client5.http.impl.Brotli4jRuntime") + static final class Brotli4jRuntime { + @Substitute + public static boolean available() { + return false; + } + } +} diff --git a/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java b/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java index ffedd7bc..368c1e34 100644 --- a/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java +++ b/commafeed-server/src/main/java/com/commafeed/backend/HttpClientFactory.java @@ -20,9 +20,7 @@ import nl.altindag.ssl.apache5.util.Apache5SslUtils; import org.apache.hc.client5.http.DnsResolver; import org.apache.hc.client5.http.SystemDefaultDnsResolver; import org.apache.hc.client5.http.async.methods.InflatingAsyncDataConsumer; -import org.apache.hc.client5.http.async.methods.InflatingBrotliDataConsumer; import org.apache.hc.client5.http.async.methods.InflatingGzipDataConsumer; -import org.apache.hc.client5.http.async.methods.InflatingZstdDataConsumer; import org.apache.hc.client5.http.config.ConnectionConfig; import org.apache.hc.client5.http.config.TlsConfig; import org.apache.hc.client5.http.entity.compress.ContentCoding; @@ -92,8 +90,6 @@ public class HttpClientFactory { contentDecoderMap.put( ContentCoding.DEFLATE.token(), d -> new InflatingAsyncDataConsumer(d, null)); contentDecoderMap.put(ContentCoding.GZIP.token(), InflatingGzipDataConsumer::new); - contentDecoderMap.put(ContentCoding.ZSTD.token(), InflatingZstdDataConsumer::new); - contentDecoderMap.put(ContentCoding.BROTLI.token(), InflatingBrotliDataConsumer::new); RedirectStrategy redirectStrategy = config.httpClient().blockLocalAddresses() diff --git a/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java b/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java index 0f11e08d..6b1aae47 100644 --- a/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java +++ b/commafeed-server/src/test/java/com/commafeed/backend/HttpGetterTest.java @@ -1,6 +1,5 @@ package com.commafeed.backend; -import com.aayushatharva.brotli4j.encoder.BrotliOutputStream; import com.codahale.metrics.MetricRegistry; import com.commafeed.CommaFeedConfiguration; import com.commafeed.CommaFeedVersion; @@ -8,7 +7,6 @@ import com.commafeed.backend.HttpGetter.HttpResponseException; import com.commafeed.backend.HttpGetter.HttpResult; import com.commafeed.backend.HttpGetter.NotModifiedException; import com.commafeed.backend.HttpGetter.TooManyRequestsException; -import com.github.luben.zstd.ZstdOutputStream; import com.google.common.net.HttpHeaders; import io.quarkus.runtime.configuration.MemorySize; @@ -422,7 +420,7 @@ class HttpGetterTest { @Nested class Compression { - private static final String ACCEPT_ENCODING = "deflate, gzip, zstd, br"; + private static final String ACCEPT_ENCODING = "deflate, gzip"; @Test void gzip() throws Exception { @@ -434,16 +432,6 @@ class HttpGetterTest { supportsCompression("deflate", DeflaterOutputStream::new); } - @Test - void zstd() throws Exception { - supportsCompression("zstd", ZstdOutputStream::new); - } - - @Test - void br() throws Exception { - supportsCompression("br", BrotliOutputStream::new); - } - void supportsCompression(String encoding, CompressionFunction compressionFunction) throws Exception { String body = "my body";