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

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new d014d7ac28 FELIX-6770 : Support new methods in Jakarta Servlet 6.1
d014d7ac28 is described below

commit d014d7ac28a7e3331bd7e54028d6b4203502e73d
Author: Carsten Ziegeler <cziege...@apache.org>
AuthorDate: Thu Apr 17 08:36:12 2025 +0200

    FELIX-6770 : Support new methods in Jakarta Servlet 6.1
---
 http/base/pom.xml                                  |  2 +-
 .../internal/dispatch/ServletRequestWrapper.java   |  5 ++-
 .../internal/dispatch/ServletResponseWrapper.java  | 42 ++++++++++++++++++++++
 http/itest/pom.xml                                 |  2 +-
 http/jetty/pom.xml                                 |  2 +-
 5 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/http/base/pom.xml b/http/base/pom.xml
index bfb5c8a988..92a7bb7356 100644
--- a/http/base/pom.xml
+++ b/http/base/pom.xml
@@ -99,7 +99,7 @@
         <dependency>
             <groupId>jakarta.servlet</groupId>
             <artifactId>jakarta.servlet-api</artifactId>
-            <version>6.0.0</version>
+            <version>6.1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
index d47f305e69..4eaa39684b 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletRequestWrapper.java
@@ -64,7 +64,7 @@ class ServletRequestWrapper extends HttpServletRequestWrapper
        private static final List<String> FORWARD_ATTRIBUTES = 
Arrays.asList(FORWARD_CONTEXT_PATH,
         FORWARD_MAPPING, FORWARD_PATH_INFO, FORWARD_QUERY_STRING, 
FORWARD_REQUEST_URI, FORWARD_SERVLET_PATH);
 
-       private static final List<String> INCLUDE_ATTRIBUTES = 
Arrays.asList(INCLUDE_CONTEXT_PATH, 
+       private static final List<String> INCLUDE_ATTRIBUTES = 
Arrays.asList(INCLUDE_CONTEXT_PATH,
         INCLUDE_MAPPING, INCLUDE_PATH_INFO, INCLUDE_QUERY_STRING, 
INCLUDE_REQUEST_URI, INCLUDE_SERVLET_PATH);
 
        private final DispatcherType type;
@@ -122,7 +122,7 @@ class ServletRequestWrapper extends 
HttpServletRequestWrapper
             else if (FORWARD_ATTRIBUTES.contains(name) ) {
                 return super.getAttribute(name);
             }
-        } 
+        }
         else if (isForwardingDispatcher() && !this.requestInfo.nameMatch)
         {
             // The jakarta.servlet.forward.* attributes refer to the 
information of the *original* request,
@@ -382,7 +382,6 @@ class ServletRequestWrapper extends 
HttpServletRequestWrapper
     }
 
     @Override
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public Collection<Part> getParts() throws IOException, ServletException {
         throw new ServletException("No Multipart-Support available");
     }
diff --git 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletResponseWrapper.java
 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletResponseWrapper.java
index 21fe8c4159..f5d1ac53c2 100644
--- 
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletResponseWrapper.java
+++ 
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/ServletResponseWrapper.java
@@ -150,4 +150,46 @@ final class ServletResponseWrapper extends 
HttpServletResponseWrapper
             super.sendError(code, message);
         }
     }
+
+
+    @Override
+    public void sendRedirect(String location, int sc) throws IOException {
+        this.sendRedirect(location, sc, true);
+    }
+
+    @Override
+    public void sendRedirect(String location, boolean clearBuffer) throws 
IOException {
+        this.sendRedirect(location, SC_FOUND, clearBuffer);
+    }
+
+    @Override
+    public void sendRedirect(final String location, final int sc, final 
boolean clearBuffer) throws IOException {
+        if (this.request.getServletContext().getMajorVersion() > 6
+            || (this.request.getServletContext().getMajorVersion() == 6 && 
this.request.getServletContext().getMinorVersion() >= 1)) {
+            // Servlet API 6.1
+            super.sendRedirect(location, sc, clearBuffer);
+        } else {
+            // Servlet API 6.0
+            if (sc == SC_FOUND && clearBuffer) {
+                this.sendRedirect(location);
+            } else {
+                if (isCommitted()) {
+                    throw new IllegalStateException("Response already 
committed");
+                }
+
+                // Ignore any call from an included servlet
+                if 
(request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) != null) {
+                    return;
+                }
+
+                if (clearBuffer) {
+                    this.resetBuffer();
+                }
+                this.setStatus(sc);
+                this.setHeader("Location", location);
+
+                this.flushBuffer();
+            }
+        }
+    }
 }
diff --git a/http/itest/pom.xml b/http/itest/pom.xml
index aa4b096fdf..23f6adf978 100644
--- a/http/itest/pom.xml
+++ b/http/itest/pom.xml
@@ -45,7 +45,7 @@
             <properties>
                 <felix.java.version>17</felix.java.version>
                 <http.servlet.api.version>3.0.0</http.servlet.api.version>
-                <http.jetty.version>1.0.27-SNAPSHOT</http.jetty.version>
+                <http.jetty.version>1.0.29-SNAPSHOT</http.jetty.version>
                 <http.jetty.id>org.apache.felix.http.jetty12</http.jetty.id>
             </properties>
         </profile>
diff --git a/http/jetty/pom.xml b/http/jetty/pom.xml
index f4a1d27e8a..65733fafd7 100644
--- a/http/jetty/pom.xml
+++ b/http/jetty/pom.xml
@@ -494,7 +494,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.base</artifactId>
-            <version>5.1.11-SNAPSHOT</version>
+            <version>5.1.13-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>

Reply via email to