This is an automated email from the ASF dual-hosted git repository.

paulrutter pushed a commit to branch maintenance/FELIX-6832-fix-deprecations
in repository https://gitbox.apache.org/repos/asf/felix-dev.git

commit d1c9a29816b91a6ae3b89b4df3e687505b8268b9
Author: Paul Rütter <[email protected]>
AuthorDate: Thu May 28 13:04:29 2026 +0200

    FELIX-6832 Fix Jetty 12.1 deprecation warnings
    
    - Replace deprecated VirtualThreadPool.setMaxThreads/getMaxThreads with
      setMaxConcurrentTasks/getMaxConcurrentTasks.
    - Replace deprecated org.eclipse.jetty.server.handler.gzip.GzipHandler with
      CompressionHandler + GzipCompression + CompressionConfig from the new
      jetty-compression-server / jetty-compression-gzip modules. All include
      and exclude lists (methods, paths, mime types), min compress size, and
      sync flush are preserved via the new builder / encoder-config APIs.
    - Introduce JettyConfig.DEFAULT_GZIP_MIN_SIZE (= 32) to replace the
      no-longer-public GzipHandler.DEFAULT_MIN_GZIP_SIZE constant.
    - The org.apache.felix.jetty.gzip.inflateBufferSize property is still
      accepted to preserve OSGi config compatibility but no longer has a
      direct equivalent in the new API and is therefore not wired into the
      handler; decompression behavior follows the CompressionHandler defaults.
    - Add jetty-compression-server dependency.
---
 http/jetty12/pom.xml                               |  5 +++
 .../jetty/internal/ConfigMetaTypeProvider.java     |  5 +--
 .../felix/http/jetty/internal/JettyConfig.java     |  6 ++-
 .../felix/http/jetty/internal/JettyService.java    | 52 +++++++++++++++-------
 4 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/http/jetty12/pom.xml b/http/jetty12/pom.xml
index a50a2f2294..9e0e6c8b7d 100644
--- a/http/jetty12/pom.xml
+++ b/http/jetty12/pom.xml
@@ -696,6 +696,11 @@
             <artifactId>jetty-session</artifactId>
             <version>${jetty.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty.compression</groupId>
+            <artifactId>jetty-compression-server</artifactId>
+            <version>${jetty.version}</version>
+        </dependency>
         <dependency>
             <groupId>org.eclipse.jetty.compression</groupId>
             <artifactId>jetty-compression-gzip</artifactId>
diff --git 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
index 5086bbe0ba..a714a95dfa 100644
--- 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
+++ 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/ConfigMetaTypeProvider.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
 import org.apache.felix.http.base.internal.HttpConfig;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.eclipse.jetty.server.CustomRequestLog;
-import org.eclipse.jetty.server.handler.gzip.GzipHandler;
 import org.eclipse.jetty.session.HouseKeeper;
 import org.osgi.framework.Bundle;
 import org.osgi.service.metatype.AttributeDefinition;
@@ -375,8 +374,8 @@ class ConfigMetaTypeProvider implements MetaTypeProvider
                 
bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_GZIP_HANDLER_ENABLE)));
         adList.add(new 
AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_GZIP_MIN_GZIP_SIZE,
                 "Gzip Min Size",
-                String.format("The minimum response size to trigger dynamic 
compression. Default is %d.", GzipHandler.DEFAULT_MIN_GZIP_SIZE),
-                GzipHandler.DEFAULT_MIN_GZIP_SIZE,
+                String.format("The minimum response size to trigger dynamic 
compression. Default is %d.", JettyConfig.DEFAULT_GZIP_MIN_SIZE),
+                JettyConfig.DEFAULT_GZIP_MIN_SIZE,
                 
bundle.getBundleContext().getProperty(JettyConfig.FELIX_JETTY_GZIP_MIN_GZIP_SIZE)));
         adList.add(new 
AttributeDefinitionImpl(JettyConfig.FELIX_JETTY_GZIP_INFLATE_BUFFER_SIZE,
                 "Gzip Inflate Buffer Size",
diff --git 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
index 73c815a245..f3a7680f2d 100644
--- 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
+++ 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
@@ -31,7 +31,6 @@ import java.util.zip.Deflater;
 import org.apache.felix.http.base.internal.HttpConfig;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.eclipse.jetty.server.CustomRequestLog;
-import org.eclipse.jetty.server.handler.gzip.GzipHandler;
 import org.osgi.framework.BundleContext;
 
 public final class JettyConfig
@@ -687,8 +686,11 @@ public final class JettyConfig
         return getBooleanProperty(FELIX_JETTY_GZIP_HANDLER_ENABLE, false);
     }
 
+    /** Default minimum size of a response before it is compressed (in bytes). 
*/
+    public static final int DEFAULT_GZIP_MIN_SIZE = 32;
+
     public int getGzipMinGzipSize() {
-        return getIntProperty(FELIX_JETTY_GZIP_MIN_GZIP_SIZE, 
GzipHandler.DEFAULT_MIN_GZIP_SIZE);
+        return getIntProperty(FELIX_JETTY_GZIP_MIN_GZIP_SIZE, 
DEFAULT_GZIP_MIN_SIZE);
     }
 
     public int getGzipInflateBufferSize() {
diff --git 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
index a84cec1993..b14504bab5 100644
--- 
a/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
+++ 
b/http/jetty12/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
@@ -43,6 +43,10 @@ import jakarta.servlet.SessionTrackingMode;
 import org.apache.felix.http.base.internal.HttpServiceController;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory;
+import org.eclipse.jetty.compression.gzip.GzipCompression;
+import org.eclipse.jetty.compression.gzip.GzipEncoderConfig;
+import org.eclipse.jetty.compression.server.CompressionConfig;
+import org.eclipse.jetty.compression.server.CompressionHandler;
 import org.eclipse.jetty.ee11.servlet.ServletContextHandler;
 import org.eclipse.jetty.ee11.servlet.ServletHolder;
 import org.eclipse.jetty.ee11.servlet.SessionHandler;
@@ -63,7 +67,6 @@ import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.SizeLimitHandler;
 import org.eclipse.jetty.server.handler.StatisticsHandler;
-import org.eclipse.jetty.server.handler.gzip.GzipHandler;
 import org.eclipse.jetty.session.HouseKeeper;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
@@ -300,7 +303,7 @@ public final class JettyService
                 if (threadPoolMax >= 0) {
                     // Configurable, bounded, virtual thread executor
                     VirtualThreadPool threadPool = new VirtualThreadPool();
-                    threadPool.setMaxThreads(threadPoolMax);
+                    threadPool.setMaxConcurrentTasks(threadPoolMax);
                     this.server = new Server(threadPool);
                 } else {
                     // Simple, unlimited, virtual thread Executor
@@ -371,18 +374,37 @@ public final class JettyService
 
             if (this.config.isGzipHandlerEnabled())
             {
-               GzipHandler gzipHandler = new GzipHandler();
-               gzipHandler.setMinGzipSize(this.config.getGzipMinGzipSize());
-               
gzipHandler.setInflateBufferSize(this.config.getGzipInflateBufferSize());
-               gzipHandler.setSyncFlush(this.config.isGzipSyncFlush());
-               
gzipHandler.addIncludedMethods(this.config.getGzipIncludedMethods());
-               
gzipHandler.addExcludedMethods(this.config.getGzipExcludedMethods());
-               
gzipHandler.addIncludedPaths(this.config.getGzipIncludedPaths());
-               
gzipHandler.addExcludedPaths(this.config.getGzipExcludedPaths());
-               
gzipHandler.addIncludedMimeTypes(this.config.getGzipIncludedMimeTypes());
-               
gzipHandler.addExcludedMimeTypes(this.config.getGzipExcludedMimeTypes());
-
-               this.server.insertHandler(gzipHandler);
+               GzipCompression gzipCompression = new GzipCompression();
+               
gzipCompression.setMinCompressSize(this.config.getGzipMinGzipSize());
+               GzipEncoderConfig encoderConfig = new GzipEncoderConfig();
+               encoderConfig.setSyncFlush(this.config.isGzipSyncFlush());
+               gzipCompression.setDefaultEncoderConfig(encoderConfig);
+
+               CompressionConfig.Builder configBuilder = 
CompressionConfig.builder();
+               for (String method : this.config.getGzipIncludedMethods()) {
+                   configBuilder.compressIncludeMethod(method);
+               }
+               for (String method : this.config.getGzipExcludedMethods()) {
+                   configBuilder.compressExcludeMethod(method);
+               }
+               for (String path : this.config.getGzipIncludedPaths()) {
+                   configBuilder.compressIncludePath(path);
+               }
+               for (String path : this.config.getGzipExcludedPaths()) {
+                   configBuilder.compressExcludePath(path);
+               }
+               for (String mimeType : this.config.getGzipIncludedMimeTypes()) {
+                   configBuilder.compressIncludeMimeType(mimeType);
+               }
+               for (String mimeType : this.config.getGzipExcludedMimeTypes()) {
+                   configBuilder.compressExcludeMimeType(mimeType);
+               }
+
+               CompressionHandler compressionHandler = new 
CompressionHandler();
+               compressionHandler.putCompression(gzipCompression);
+               compressionHandler.putConfiguration("/*", 
configBuilder.build());
+
+               this.server.insertHandler(compressionHandler);
             }
 
             if(this.config.getStopTimeout() != -1)
@@ -440,7 +462,7 @@ public final class JettyService
                     
message.append("maxThreads=").append(sizedThreadPool.getMaxThreads()).append(",");
                 } else if (threadPool instanceof VirtualThreadPool) {
                     VirtualThreadPool sizedThreadPool = (VirtualThreadPool) 
threadPool;
-                    
message.append("maxVirtualThreads=").append(sizedThreadPool.getMaxThreads()).append(",");
+                    
message.append("maxVirtualThreads=").append(sizedThreadPool.getMaxConcurrentTasks()).append(",");
                 }
                 Connector connector = this.server.getConnectors()[0];
                 if (connector instanceof ServerConnector) {

Reply via email to