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 8a32c6434d FELIX-6671 : Support Jakarta Servlet 5 and 6 with a single
implementation
8a32c6434d is described below
commit 8a32c6434db472134415f70abfceac758ffec604
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Mon Nov 27 09:56:27 2023 +0100
FELIX-6671 : Support Jakarta Servlet 5 and 6 with a single implementation
---
http/base/pom.xml | 2 +-
.../internal/context/ExtServletContextWrapper.java | 16 +++--------
.../internal/dispatch/IncludeResponseWrapper.java | 1 -
.../internal/dispatch/ServletRequestWrapper.java | 3 +-
.../base/internal/handler/HttpSessionWrapper.java | 13 ---------
.../base/internal/service/ServletContextImpl.java | 11 ++------
.../whiteboard/PerBundleServletContextImpl.java | 16 +++--------
.../whiteboard/SharedServletContextImpl.java | 13 ++-------
.../internal/context/ServletContextImplTest.java | 32 +++-------------------
.../dispatch/IncludeResponseWrapperTest.java | 2 +-
http/bridge/pom.xml | 2 +-
http/jetty/pom.xml | 2 +-
12 files changed, 23 insertions(+), 90 deletions(-)
diff --git a/http/base/pom.xml b/http/base/pom.xml
index 1bfe8b3372..0b4d50617f 100644
--- a/http/base/pom.xml
+++ b/http/base/pom.xml
@@ -57,7 +57,7 @@
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
- <version>5.0.0</version>
+ <version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/context/ExtServletContextWrapper.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/context/ExtServletContextWrapper.java
index 25da93677a..6b43ebe702 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/context/ExtServletContextWrapper.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/context/ExtServletContextWrapper.java
@@ -159,25 +159,19 @@ public abstract class ExtServletContextWrapper implements
ExtServletContext
return delegate.getNamedDispatcher(name);
}
- @Override
- @SuppressWarnings("deprecation")
public Servlet getServlet(final String name) throws ServletException
{
- return delegate.getServlet(name);
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
- @Override
- @SuppressWarnings("deprecation")
public Enumeration<Servlet> getServlets()
{
- return delegate.getServlets();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
- @Override
- @SuppressWarnings("deprecation")
public Enumeration<String> getServletNames()
{
- return delegate.getServletNames();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -186,11 +180,9 @@ public abstract class ExtServletContextWrapper implements
ExtServletContext
delegate.log(msg);
}
- @Override
- @SuppressWarnings("deprecation")
public void log(final Exception exception, final String msg)
{
- delegate.log(exception, msg);
+ delegate.log(msg, exception);
}
@Override
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapper.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapper.java
index 7264db4c13..2801e5a934 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapper.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapper.java
@@ -122,7 +122,6 @@ public class IncludeResponseWrapper extends
HttpServletResponseWrapper {
// ignore
}
- @Override
public void setStatus(final int sc, final String msg) {
// ignore
}
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 02f64fc76f..603c99b6c9 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
@@ -238,11 +238,10 @@ final class ServletRequestWrapper extends
HttpServletRequestWrapper
}
@Override
- @SuppressWarnings("deprecation")
public String getPathTranslated()
{
final String info = getPathInfo();
- return (null == info) ? null : getRealPath(info);
+ return (null == info) ? null : getServletContext().getRealPath(info);
}
@Override
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
index 9165689b6f..dba883e225 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpSessionWrapper.java
@@ -31,7 +31,6 @@ import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpSession;
import jakarta.servlet.http.HttpSessionBindingEvent;
import jakarta.servlet.http.HttpSessionBindingListener;
-import jakarta.servlet.http.HttpSessionContext;
import jakarta.servlet.http.HttpSessionEvent;
import org.apache.felix.http.base.internal.HttpConfig;
@@ -41,7 +40,6 @@ import
org.apache.felix.http.base.internal.context.ExtServletContext;
* The session wrapper keeps track of the internal session, manages their
attributes
* separately and also handles session timeout.
*/
-@SuppressWarnings("deprecation")
public class HttpSessionWrapper implements HttpSession
{
/** All special attributes are prefixed with this prefix. */
@@ -301,14 +299,12 @@ public class HttpSessionWrapper implements HttpSession
return this.context;
}
- @Override
public Object getValue(String name)
{
this.checkInvalid();
return this.getAttribute(name);
}
- @Override
public String[] getValueNames()
{
this.checkInvalid();
@@ -380,7 +376,6 @@ public class HttpSessionWrapper implements HttpSession
return this.isNew;
}
- @Override
public void putValue(final String name, final Object value)
{
this.checkInvalid();
@@ -406,7 +401,6 @@ public class HttpSessionWrapper implements HttpSession
}
}
- @Override
public void removeValue(final String name)
{
this.checkInvalid();
@@ -468,13 +462,6 @@ public class HttpSessionWrapper implements HttpSession
}
}
- @Override
- public HttpSessionContext getSessionContext()
- {
- // no need to check validity conforming to the javadoc
- return this.delegate.getSessionContext();
- }
-
private static final class SessionBindingValueListenerWrapper implements
Serializable
{
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
index 98f14b830e..de63b4f133 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
@@ -66,7 +66,6 @@ import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionListener;
import jakarta.servlet.http.MappingMatch;
-@SuppressWarnings("deprecation")
public class ServletContextImpl implements ExtServletContext
{
private final Bundle bundle;
@@ -346,10 +345,9 @@ public class ServletContextImpl implements
ExtServletContext
return this.context.getServerInfo();
}
- @Override
public Servlet getServlet(String name) throws ServletException
{
- return this.context.getServlet(name);
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -358,10 +356,9 @@ public class ServletContextImpl implements
ExtServletContext
return HttpServiceFactory.HTTP_SERVICE_CONTEXT_NAME;
}
- @Override
public Enumeration<String> getServletNames()
{
- return this.context.getServletNames();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -376,10 +373,9 @@ public class ServletContextImpl implements
ExtServletContext
return this.context.getServletRegistrations();
}
- @Override
public Enumeration<Servlet> getServlets()
{
- return this.context.getServlets();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -424,7 +420,6 @@ public class ServletContextImpl implements ExtServletContext
// nothing to do
}
- @Override
public void log(Exception cause, String message)
{
SystemLogger.LOGGER.error(message, cause);
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerBundleServletContextImpl.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerBundleServletContextImpl.java
index 8e98a18227..2678503f74 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerBundleServletContextImpl.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/PerBundleServletContextImpl.java
@@ -220,25 +220,19 @@ public class PerBundleServletContextImpl implements
ExtServletContext {
return delegatee.getNamedDispatcher(name);
}
- @SuppressWarnings("deprecation")
- @Override
public Servlet getServlet(String name) throws ServletException
{
- return delegatee.getServlet(name);
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
- @SuppressWarnings("deprecation")
- @Override
public Enumeration<Servlet> getServlets()
{
- return delegatee.getServlets();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
- @SuppressWarnings("deprecation")
- @Override
public Enumeration<String> getServletNames()
{
- return delegatee.getServletNames();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -247,11 +241,9 @@ public class PerBundleServletContextImpl implements
ExtServletContext {
delegatee.log(msg);
}
- @SuppressWarnings("deprecation")
- @Override
public void log(Exception exception, String msg)
{
- delegatee.log(exception, msg);
+ delegatee.log(msg, exception);
}
@Override
diff --git
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/SharedServletContextImpl.java
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/SharedServletContextImpl.java
index 1327b4f1b3..12b3c0410d 100644
---
a/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/SharedServletContextImpl.java
+++
b/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/SharedServletContextImpl.java
@@ -381,11 +381,9 @@ public class SharedServletContextImpl implements
ServletContext
return this.context.getServerInfo();
}
- @SuppressWarnings("deprecation")
- @Override
public Servlet getServlet(final String name) throws ServletException
{
- return this.context.getServlet(name);
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -394,11 +392,9 @@ public class SharedServletContextImpl implements
ServletContext
return this.name;
}
- @SuppressWarnings("deprecation")
- @Override
public Enumeration<String> getServletNames()
{
- return this.context.getServletNames();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -413,11 +409,9 @@ public class SharedServletContextImpl implements
ServletContext
return this.context.getServletRegistrations();
}
- @SuppressWarnings("deprecation")
- @Override
public Enumeration<Servlet> getServlets()
{
- return this.context.getServlets();
+ throw new UnsupportedOperationException("Deprecated method not
supported");
}
@Override
@@ -426,7 +420,6 @@ public class SharedServletContextImpl implements
ServletContext
return this.context.getSessionCookieConfig();
}
- @Override
public void log(final Exception cause, final String message)
{
SystemLogger.LOGGER.error(message, cause);
diff --git
a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
index f6d5bc420f..1423962ac6 100644
---
a/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
+++
b/http/base/src/test/java/org/apache/felix/http/base/internal/context/ServletContextImplTest.java
@@ -364,8 +364,8 @@ public class ServletContextImplTest
return null;
}
+ @SuppressWarnings("unused")
@Deprecated
- @Override
public Servlet getServlet(String name)
{
return null;
@@ -377,9 +377,8 @@ public class ServletContextImplTest
return null;
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes", "unused"})
@Deprecated
- @Override
public Enumeration getServletNames()
{
return Collections.enumeration(Collections.emptyList());
@@ -397,9 +396,8 @@ public class ServletContextImplTest
return null;
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings({ "rawtypes", "unused" })
@Deprecated
- @Override
public Enumeration getServlets()
{
return Collections.enumeration(Collections.emptyList());
@@ -411,8 +409,8 @@ public class ServletContextImplTest
return null;
}
+ @SuppressWarnings("unused")
@Deprecated
- @Override
public void log(Exception exception, String msg)
{
}
@@ -627,28 +625,6 @@ public class ServletContextImplTest
Assert.assertTrue(set.contains("/some/path/2"));
}
- @Test
- public void testGetServlet() throws Exception
- {
- Assert.assertNull(this.context.getServlet("test"));
- }
-
- @Test
- public void testGetServletNames()
- {
- Enumeration<String> e = this.context.getServletNames();
- Assert.assertNotNull(e);
- Assert.assertFalse(e.hasMoreElements());
- }
-
- @Test
- public void testGetServlets()
- {
- Enumeration<Servlet> e = this.context.getServlets();
- Assert.assertNotNull(e);
- Assert.assertFalse(e.hasMoreElements());
- }
-
@Test
public void testGetSharedAttribute()
{
diff --git
a/http/base/src/test/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapperTest.java
b/http/base/src/test/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapperTest.java
index 3c841ba4b0..845260d71e 100644
---
a/http/base/src/test/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapperTest.java
+++
b/http/base/src/test/java/org/apache/felix/http/base/internal/dispatch/IncludeResponseWrapperTest.java
@@ -79,7 +79,7 @@ public class IncludeResponseWrapperTest {
@Deprecated
@Test public void testSetStatus() {
final HttpServletResponse orig =
Mockito.mock(HttpServletResponse.class);
- final HttpServletResponse include = new IncludeResponseWrapper(orig);
+ final IncludeResponseWrapper include = new
IncludeResponseWrapper(orig);
include.setStatus(500);
include.setStatus(500, "Error");
diff --git a/http/bridge/pom.xml b/http/bridge/pom.xml
index ca1595241d..c363e0ecbc 100644
--- a/http/bridge/pom.xml
+++ b/http/bridge/pom.xml
@@ -167,7 +167,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>5.1.2</version>
+ <version>5.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
diff --git a/http/jetty/pom.xml b/http/jetty/pom.xml
index 76f5f68ebe..2a902c5313 100644
--- a/http/jetty/pom.xml
+++ b/http/jetty/pom.xml
@@ -412,7 +412,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.base</artifactId>
- <version>5.1.2</version>
+ <version>5.1.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>