Skip to content

Commit 5d943bf

Browse files
committedFeb 14, 2025
[#1802] Switch pax-web-undertow from javax to jakarta
1 parent a7a6ee2 commit 5d943bf

24 files changed

+327
-336
lines changed
 

‎pax-web-api/src/main/java/org/ops4j/pax/web/service/PaxWebConfig.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,28 @@ public interface PaxWebConfig {
6565
* This property specifies the port used for servlets and resources accessible via HTTP.
6666
* The default value for this property is {@code 80} according to specification, but we'll use {@code 8080}.
6767
*/
68-
String PID_CFG_HTTP_PORT = "org.osgi.service.servlet.port";
68+
String PID_CFG_HTTP_PORT = "org.osgi.service.http.port";
6969

7070
/**
7171
* This property specifies the port used for servlets and resources accessible via HTTPS.
7272
* The default value for this property is {@code 443} according to specificaton, but we'll use {@code 8443}.
7373
*/
74-
String PID_CFG_HTTP_PORT_SECURE = "org.osgi.service.servlet.port.secure";
74+
String PID_CFG_HTTP_PORT_SECURE = "org.osgi.service.http.port.secure";
7575

7676
/** Should the default non-secure port be enabled? */
77-
String PID_CFG_HTTP_ENABLED = "org.osgi.service.servlet.enabled";
77+
String PID_CFG_HTTP_ENABLED = "org.osgi.service.http.enabled";
7878

7979
/** Should the default secure port be enabled? */
80-
String PID_CFG_HTTP_SECURE_ENABLED = "org.osgi.service.servlet.secure.enabled";
80+
String PID_CFG_HTTP_SECURE_ENABLED = "org.osgi.service.http.secure.enabled";
8181

8282
/** Comma-separated list of addresses to bind listeners/connectors to. Defaults to {@code 0.0.0.0} */
8383
String PID_CFG_LISTENING_ADDRESSES = "org.ops4j.pax.web.listening.addresses";
8484

8585
/** Name to use as <em>default</em> (non-secure) connector, defaults to {@code default}. */
86-
String PID_CFG_HTTP_CONNECTOR_NAME = "org.osgi.service.servlet.connector.name";
86+
String PID_CFG_HTTP_CONNECTOR_NAME = "org.osgi.service.http.connector.name";
8787

8888
/** Name to use as <em>secure</em> connector, defaults to {@code secureDefault}. */
89-
String PID_CFG_HTTP_SECURE_CONNECTOR_NAME = "org.osgi.service.servlet.secure.connector.name";
89+
String PID_CFG_HTTP_SECURE_CONNECTOR_NAME = "org.osgi.service.http.secure.connector.name";
9090

9191
/**
9292
* Jetty: {@code org.eclipse.jetty.server.AbstractConnector#setIdleTimeout(long)}
@@ -119,7 +119,7 @@ public interface PaxWebConfig {
119119
/**
120120
* Jetty: adds {@code org.eclipse.jetty.server.ForwardedRequestCustomizer} to {@code HttpConfiguration}
121121
*/
122-
String PID_CFG_HTTP_CHECK_FORWARDED_HEADERS = "org.osgi.service.servlet.checkForwardedHeaders";
122+
String PID_CFG_HTTP_CHECK_FORWARDED_HEADERS = "org.osgi.service.http.checkForwardedHeaders";
123123

124124
/**
125125
* Comma-separated list of virtual hosts to set on <em>every deployed context</em> if the context itself

‎pax-web-undertow/internals.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ QueuedNioTcpServer@10249 = "TCP server (NIO) <b75f502>"
5757
<2> This is default handler invoked when nothing is matched using <4>
5858
<3> PathHandler will be drilled down later
5959
<4> These 4 welcome pages are defaults from `io.undertow.server.handlers.resource.ResourceHandler.welcomeFiles`
60-
<5> Standard javax.servlet context mapping
60+
<5> Standard jakarta.servlet context mapping
6161

6262
Here's how `io.undertow.Undertow` (Wildfly's version is `org.wildfly.extension.undertow.Server`)
6363
instance can be found (there's one instance of this class):
@@ -149,7 +149,7 @@ next: {io.undertow.server.handlers.PathHandler@10199}
149149
<2> Path matching within single web application
150150
<3> Servlets of web application
151151
<4> The actual instance of one of the the servlets
152-
<5> Resource manager for calls to e.g., `javax.servlet.ServletContext.getResource()`
152+
<5> Resource manager for calls to e.g., `jakarta.servlet.ServletContext.getResource()`
153153

154154
Here's what really is invoked by `io.undertow.servlet.handlers.ServletDispatchingHandler`:
155155

‎pax-web-undertow/pom.xml

+52-42
Original file line numberDiff line numberDiff line change
@@ -43,62 +43,62 @@
4343
<instructions>
4444
<Bundle-Activator>org.ops4j.pax.web.service.undertow.internal.Activator</Bundle-Activator>
4545
<Import-Package>
46-
<!-- ranges indicate Servlet API 3.1+ (JavaEE 7+) -->
47-
javax.servlet;version="[3.1,5)",
48-
javax.servlet.annotation;version="[3.1,5)",
49-
javax.servlet.descriptor;version="[3.1,5)",
50-
javax.servlet.http;version="[3.1,5)",
51-
52-
<!-- ranges indicate we can work with OSGi Core R6+ -->
53-
org.osgi.framework;version="[1.8,2)",
46+
<!-- ranges indicate Servlet API 6.0+ (JakartaEE 10+) -->
47+
jakarta.servlet;version="[6,7)",
48+
jakarta.servlet.annotation;version="[6,7)",
49+
jakarta.servlet.descriptor;version="[6,7)",
50+
jakarta.servlet.http;version="[6,7)",
51+
52+
<!-- OSGi Core R8+ -->
53+
org.osgi.framework;version="[1.10,2)",
5454
org.osgi.framework.wiring;version="[1.2,2)",
5555
org.osgi.util.tracker;version="[1.5,2)",
5656

5757
<!-- OSGi cmpn -->
58-
org.osgi.service.http;version="[1.2,2)",
59-
org.osgi.service.http.whiteboard;version="[1.1,2)",
58+
org.osgi.service.servlet.whiteboard;version="[2,3)",
6059

6160
<!-- from pax-web-api -->
6261
org.ops4j.pax.web.service;version="${pax-web.osgi.version}",
62+
org.ops4j.pax.web.service.http;version="${pax-web.osgi.version}",
6363
org.ops4j.pax.web.utils;version="${pax-web.osgi.version}",
6464
<!-- from pax-web-spi -->
6565
org.ops4j.pax.web.service.spi.*;version="${pax-web.osgi.version}",
6666

6767
<!-- from pax-logging-api -->
68-
org.slf4j;version="[1.7,2)",
68+
org.slf4j;version="[2,3)",
6969
org.jboss.logging;version="[3.4,4)",
7070

7171
<!-- undertow and xnio packages -->
7272
org.xnio;version="[3.8,4)",
7373
org.xnio.channels;version="[3.8,4)",
74-
io.undertow;version="[2.2,3)",
75-
io.undertow.connector;version="[2.2,3)",
76-
io.undertow.io;version="[2.2,3)",
77-
io.undertow.predicate;version="[2.2,3)",
78-
io.undertow.protocols.ssl;version="[2.2,3)",
79-
io.undertow.security.api;version="[2.2,3)",
80-
io.undertow.security.idm;version="[2.2,3)",
81-
io.undertow.security.impl;version="[2.2,3)",
82-
io.undertow.server;version="[2.2,3)",
83-
io.undertow.server.handlers;version="[2.2,3)",
84-
io.undertow.server.handlers.accesslog;version="[2.2,3)",
85-
io.undertow.server.handlers.builder;version="[2.2,3)",
86-
io.undertow.server.handlers.cache;version="[2.2,3)",
87-
io.undertow.server.handlers.encoding;version="[2.2,3)",
88-
io.undertow.server.handlers.resource;version="[2.2,3)",
89-
io.undertow.server.protocol.http;version="[2.2,3)",
90-
io.undertow.server.protocol.http2;version="[2.2,3)",
91-
io.undertow.server.session;version="[2.2,3)",
92-
io.undertow.servlet;version="[2.2,3)",
93-
io.undertow.servlet.api;version="[2.2,3)",
94-
io.undertow.servlet.core;version="[2.2,3)",
95-
io.undertow.servlet.handlers;version="[2.2,3)",
96-
io.undertow.servlet.spec;version="[2.2,3)",
97-
io.undertow.servlet.util;version="[2.2,3)",
98-
io.undertow.util;version="[2.2,3)",
74+
io.undertow;version="[2.3,3)",
75+
io.undertow.connector;version="[2.3,3)",
76+
io.undertow.io;version="[2.3,3)",
77+
io.undertow.predicate;version="[2.3,3)",
78+
io.undertow.protocols.ssl;version="[2.3,3)",
79+
io.undertow.security.api;version="[2.3,3)",
80+
io.undertow.security.idm;version="[2.3,3)",
81+
io.undertow.security.impl;version="[2.3,3)",
82+
io.undertow.server;version="[2.3,3)",
83+
io.undertow.server.handlers;version="[2.3,3)",
84+
io.undertow.server.handlers.accesslog;version="[2.3,3)",
85+
io.undertow.server.handlers.builder;version="[2.3,3)",
86+
io.undertow.server.handlers.cache;version="[2.3,3)",
87+
io.undertow.server.handlers.encoding;version="[2.3,3)",
88+
io.undertow.server.handlers.resource;version="[2.3,3)",
89+
io.undertow.server.protocol.http;version="[2.3,3)",
90+
io.undertow.server.protocol.http2;version="[2.3,3)",
91+
io.undertow.server.session;version="[2.3,3)",
92+
io.undertow.servlet;version="[2.3,3)",
93+
io.undertow.servlet.api;version="[2.3,3)",
94+
io.undertow.servlet.core;version="[2.3,3)",
95+
io.undertow.servlet.handlers;version="[2.3,3)",
96+
io.undertow.servlet.spec;version="[2.3,3)",
97+
io.undertow.servlet.util;version="[2.3,3)",
98+
io.undertow.util;version="[2.3,3)",
9999

100100
<!-- other -->
101-
javax.annotation;version="[1.2,2)";resolution:=optional,
101+
jakarta.annotation;version="[2,3)";resolution:=optional,
102102
javax.net.ssl,
103103
javax.security.auth,
104104
javax.security.auth.callback,
@@ -164,11 +164,11 @@
164164
</dependency>
165165
<dependency>
166166
<groupId>org.osgi</groupId>
167-
<artifactId>osgi.cmpn</artifactId>
167+
<artifactId>org.osgi.service.servlet</artifactId>
168168
<scope>provided</scope>
169169
</dependency>
170170

171-
<!-- JavaEE -->
171+
<!-- JakartaEE -->
172172

173173
<dependency>
174174
<groupId>jakarta.annotation</groupId>
@@ -226,9 +226,14 @@
226226
<artifactId>jul-to-slf4j</artifactId>
227227
<scope>provided</scope>
228228
</dependency>
229+
<dependency>
230+
<groupId>org.assertj</groupId>
231+
<artifactId>assertj-core</artifactId>
232+
<scope>test</scope>
233+
</dependency>
229234
<dependency>
230235
<groupId>org.apache.logging.log4j</groupId>
231-
<artifactId>log4j-slf4j-impl</artifactId>
236+
<artifactId>log4j-slf4j2-impl</artifactId>
232237
<scope>test</scope>
233238
</dependency>
234239

@@ -259,8 +264,13 @@
259264
<!-- Testing -->
260265

261266
<dependency>
262-
<groupId>junit</groupId>
263-
<artifactId>junit</artifactId>
267+
<groupId>org.junit.jupiter</groupId>
268+
<artifactId>junit-jupiter-api</artifactId>
269+
<scope>test</scope>
270+
</dependency>
271+
<dependency>
272+
<groupId>org.junit.jupiter</groupId>
273+
<artifactId>junit-jupiter-engine</artifactId>
264274
<scope>test</scope>
265275
</dependency>
266276
<dependency>

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/configuration/model/UndertowSubsystem.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public static CustomFilter create(Map<QName, String> attributes, Locator locator
410410

411411
@Override
412412
public HttpHandler configure(HttpHandler handler, Predicate predicate) {
413-
// TODO: use javax.servlet filters or just generic io.undertow.server.HttpHandler?
413+
// TODO: use jakarta.servlet filters or just generic io.undertow.server.HttpHandler?
414414
return handler;
415415
}
416416

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/ContextAwarePathHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

1818
import java.util.Dictionary;
19-
import javax.servlet.Servlet;
19+
import jakarta.servlet.Servlet;
2020

2121
import io.undertow.Handlers;
2222
import io.undertow.server.HttpHandler;
@@ -25,13 +25,13 @@
2525
import io.undertow.server.handlers.ResponseCodeHandler;
2626
import io.undertow.server.handlers.cache.LRUCache;
2727
import org.ops4j.pax.web.annotations.Review;
28-
import org.osgi.service.http.HttpContext;
28+
import org.ops4j.pax.web.service.http.HttpContext;
2929

3030
/**
3131
* <p>A {@link PathHandler} that can (try to) resolve conflicts when registering multiple contexts under
3232
* the same path.</p>
3333
* <p>The problem is that when using {@code etc/undertow.xml} with {@code <location>} handlers <strong>and</strong>
34-
* when using normal WARs and {@link org.osgi.service.http.HttpService#registerServlet(String, Servlet, Dictionary, HttpContext)} we may
34+
* when using normal WARs and {@link org.ops4j.pax.web.service.http.HttpService#registerServlet(String, Servlet, Dictionary, HttpContext)} we may
3535
* end up with multiple {@link io.undertow.server.HttpHandler handlers} handling {@code "/"} path. We should always prefer
3636
* the path from {@code etc/undertow.xml} configuration - assuming it's configured and user know what (s)he's
3737
* doing.</p>

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/PaxWebFilterInfo.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

1818
import java.util.Map;
19-
import javax.servlet.Filter;
20-
import javax.servlet.ServletContext;
19+
import jakarta.servlet.Filter;
20+
import jakarta.servlet.ServletContext;
2121

2222
import io.undertow.servlet.api.FilterInfo;
2323
import io.undertow.servlet.api.InstanceFactory;
@@ -31,7 +31,7 @@
3131
import org.osgi.framework.BundleContext;
3232
import org.osgi.framework.ServiceObjects;
3333
import org.osgi.framework.ServiceReference;
34-
import org.osgi.service.http.runtime.dto.DTOConstants;
34+
import org.osgi.service.servlet.runtime.dto.DTOConstants;
3535

3636
/**
3737
* Special {@link FilterInfo} that can be configured from {@link FilterModel}.
@@ -40,7 +40,7 @@ public class PaxWebFilterInfo extends FilterInfo {
4040

4141
private final FilterModel filterModel;
4242

43-
/** This {@link ServletContext} is scoped to single {@link org.osgi.service.http.context.ServletContextHelper} */
43+
/** This {@link ServletContext} is scoped to single {@link org.osgi.service.servlet.context.ServletContextHelper} */
4444
private final OsgiServletContext osgiServletContext;
4545

4646
private ServiceReference<? extends Filter> serviceReference;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/PaxWebOuterHandlerWrapper.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

18-
import javax.servlet.ServletContext;
19-
import javax.servlet.http.HttpServletRequest;
18+
import jakarta.servlet.ServletContext;
19+
import jakarta.servlet.http.HttpServletRequest;
2020

2121
import io.undertow.server.HandlerWrapper;
2222
import io.undertow.server.HttpHandler;
@@ -32,7 +32,7 @@
3232
import org.ops4j.pax.web.service.spi.servlet.OsgiSessionAttributeListener;
3333

3434
/**
35-
* This {@link HandlerWrapper} ensures that {@link org.osgi.service.http.whiteboard.Preprocessor preprocessors},
35+
* This {@link HandlerWrapper} ensures that {@link org.osgi.service.servlet.whiteboard.Preprocessor preprocessors},
3636
* filters and target servlet use proper request wrapper that returns proper {@link ServletContext}.
3737
*/
3838
public class PaxWebOuterHandlerWrapper implements HandlerWrapper {

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/PaxWebPreprocessorsHandler.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,23 @@
2020
import java.util.List;
2121
import java.util.function.Consumer;
2222
import java.util.stream.Collectors;
23-
import javax.servlet.FilterChain;
24-
import javax.servlet.ServletContext;
25-
import javax.servlet.ServletRequest;
26-
import javax.servlet.ServletResponse;
27-
import javax.servlet.http.HttpServletRequest;
28-
import javax.servlet.http.HttpServletResponse;
23+
import jakarta.servlet.FilterChain;
24+
import jakarta.servlet.ServletContext;
25+
import jakarta.servlet.ServletRequest;
26+
import jakarta.servlet.ServletResponse;
27+
import jakarta.servlet.http.HttpServletRequest;
28+
import jakarta.servlet.http.HttpServletResponse;
2929

3030
import io.undertow.server.HandlerWrapper;
3131
import io.undertow.server.HttpHandler;
3232
import io.undertow.server.HttpServerExchange;
3333
import io.undertow.servlet.handlers.ServletRequestContext;
3434
import org.ops4j.pax.web.service.spi.servlet.OsgiFilterChain;
3535
import org.ops4j.pax.web.service.spi.servlet.PreprocessorFilterConfig;
36-
import org.osgi.service.http.whiteboard.Preprocessor;
36+
import org.osgi.service.servlet.whiteboard.Preprocessor;
3737

3838
/**
39-
* This {@link HandlerWrapper} ensures that {@link org.osgi.service.http.whiteboard.Preprocessor preprocessors},
39+
* This {@link HandlerWrapper} ensures that {@link org.osgi.service.servlet.whiteboard.Preprocessor preprocessors},
4040
* filters and target servlet use proper request wrapper that returns proper {@link ServletContext}.
4141
*/
4242
public class PaxWebPreprocessorsHandler implements HandlerWrapper {

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/PaxWebSecurityHandler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

18-
import javax.servlet.Servlet;
19-
import javax.servlet.http.HttpServletRequest;
20-
import javax.servlet.http.HttpServletResponse;
18+
import jakarta.servlet.Servlet;
19+
import jakarta.servlet.http.HttpServletRequest;
20+
import jakarta.servlet.http.HttpServletResponse;
2121

2222
import io.undertow.security.api.SecurityContext;
2323
import io.undertow.server.HandlerWrapper;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/PaxWebServletInfo.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

18-
import javax.servlet.Servlet;
19-
import javax.servlet.ServletContext;
18+
import jakarta.servlet.Servlet;
19+
import jakarta.servlet.ServletContext;
2020

2121
import io.undertow.servlet.api.InstanceFactory;
2222
import io.undertow.servlet.api.InstanceHandle;
@@ -33,7 +33,7 @@
3333
import org.osgi.framework.Bundle;
3434
import org.osgi.framework.BundleContext;
3535
import org.osgi.framework.ServiceObjects;
36-
import org.osgi.service.http.runtime.dto.DTOConstants;
36+
import org.osgi.service.servlet.runtime.dto.DTOConstants;
3737

3838
import java.util.ArrayList;
3939
import java.util.List;
@@ -52,7 +52,7 @@ public class PaxWebServletInfo extends ServletInfo {
5252

5353
private Class<? extends Servlet> servletClass;
5454

55-
/** This {@link ServletContext} is scoped to single {@link org.osgi.service.http.context.ServletContextHelper} */
55+
/** This {@link ServletContext} is scoped to single {@link org.osgi.service.servlet.context.ServletContextHelper} */
5656
private final OsgiServletContext osgiServletContext;
5757
/** This {@link ServletContext} is scoped to particular Whiteboard servlet */
5858
private final OsgiScopedServletContext servletContext;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/UndertowServerController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Collections;
2222
import java.util.LinkedHashSet;
2323
import java.util.Set;
24-
import javax.servlet.Servlet;
24+
import jakarta.servlet.Servlet;
2525

2626
import io.undertow.security.idm.IdentityManager;
2727
import org.ops4j.pax.web.service.spi.ServerController;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/UndertowServerWrapper.java

+20-20
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646
import java.util.TreeSet;
4747
import java.util.UUID;
4848
import java.util.function.Supplier;
49-
import javax.servlet.DispatcherType;
50-
import javax.servlet.Servlet;
51-
import javax.servlet.ServletContext;
52-
import javax.servlet.ServletContextAttributeListener;
53-
import javax.servlet.ServletContextEvent;
54-
import javax.servlet.ServletContextListener;
55-
import javax.servlet.ServletException;
56-
import javax.servlet.SessionCookieConfig;
57-
import javax.servlet.annotation.ServletSecurity;
58-
import javax.servlet.http.HttpSessionAttributeListener;
49+
import jakarta.servlet.DispatcherType;
50+
import jakarta.servlet.Servlet;
51+
import jakarta.servlet.ServletContext;
52+
import jakarta.servlet.ServletContextAttributeListener;
53+
import jakarta.servlet.ServletContextEvent;
54+
import jakarta.servlet.ServletContextListener;
55+
import jakarta.servlet.ServletException;
56+
import jakarta.servlet.SessionCookieConfig;
57+
import jakarta.servlet.annotation.ServletSecurity;
58+
import jakarta.servlet.http.HttpSessionAttributeListener;
5959
import javax.xml.XMLConstants;
6060
import javax.xml.parsers.SAXParserFactory;
6161

@@ -182,7 +182,7 @@
182182
import org.osgi.framework.Bundle;
183183
import org.osgi.framework.FrameworkUtil;
184184
import org.osgi.framework.wiring.BundleWiring;
185-
import org.osgi.service.http.whiteboard.Preprocessor;
185+
import org.osgi.service.servlet.whiteboard.Preprocessor;
186186
import org.slf4j.Logger;
187187
import org.slf4j.LoggerFactory;
188188
import org.xml.sax.InputSource;
@@ -304,8 +304,8 @@ class UndertowServerWrapper implements BatchVisitor, UndertowSupport {
304304
private final Map<String, PaxWebPreprocessorsHandler> preprocessorsHandlers = new HashMap<>();
305305

306306
/**
307-
* Handlers that call {@link org.osgi.service.http.HttpContext#handleSecurity} and/or
308-
* {@link org.osgi.service.http.context.ServletContextHelper#handleSecurity}.
307+
* Handlers that call {@link org.ops4j.pax.web.service.http.HttpContext#handleSecurity} and/or
308+
* {@link org.osgi.service.servlet.context.ServletContextHelper#handleSecurity}.
309309
*/
310310
private final Map<String, PaxWebSecurityHandler> securityHandlers = new HashMap<>();
311311

@@ -318,14 +318,14 @@ class UndertowServerWrapper implements BatchVisitor, UndertowSupport {
318318
private final Map<String, DeploymentInfo> deploymentInfos = new HashMap<>();
319319

320320
/**
321-
* 1:1 mapping between {@link OsgiContextModel} and {@link org.osgi.service.http.context.ServletContextHelper}'s
322-
* specific {@link javax.servlet.ServletContext}.
321+
* 1:1 mapping between {@link OsgiContextModel} and {@link org.osgi.service.servlet.context.ServletContextHelper}'s
322+
* specific {@link jakarta.servlet.ServletContext}.
323323
*/
324324
private final Map<OsgiContextModel, OsgiServletContext> osgiServletContexts = new HashMap<>();
325325

326326
/**
327327
* 1:N mapping between context path and sorted (by ranking rules) set of {@link OsgiContextModel}. This helps
328-
* finding proper {@link org.osgi.service.http.context.ServletContextHelper} (1:1 with {@link OsgiContextModel})
328+
* finding proper {@link org.osgi.service.servlet.context.ServletContextHelper} (1:1 with {@link OsgiContextModel})
329329
* to use for filters, when the invocation chain doesn't contain target servlet (which otherwise would
330330
* determine the ServletContextHelper to use).
331331
*/
@@ -1563,7 +1563,7 @@ public void visitServletModelChange(ServletModelChange change) {
15631563
info.setRunAs(model.getRunAs());
15641564

15651565
// when only adding new servlet, we can simply alter existing deployment
1566-
// because this is possible (as required by methods like javax.servlet.ServletContext.addServlet())
1566+
// because this is possible (as required by methods like jakarta.servlet.ServletContext.addServlet())
15671567
// we can't go the easy way when _removing_ servlets
15681568
deploymentInfo.addServlet(info);
15691569
if (deployment != null) {
@@ -2372,7 +2372,7 @@ public void visitContainerInitializerModelChange(ContainerInitializerModelChange
23722372
if (initializers != null) {
23732373
// just remove the ServletContainerInitializerInfo without _cleaning_ it, because it was
23742374
// _cleaned_ just after io.undertow.servlet.core.DeploymentManagerImpl.deploy() called
2375-
// javax.servlet.ServletContainerInitializer.onStartup()
2375+
// jakarta.servlet.ServletContainerInitializer.onStartup()
23762376
initializers.removeIf(i -> i.getModel() == model);
23772377
}
23782378
});
@@ -2650,7 +2650,7 @@ private void ensureServletContextStarted(final String contextPath) {
26502650
deployment.addServletExtension(new ContextLinkingServletExtension(contextPath, highestRankedContext, highestRankedDynamicContext));
26512651

26522652
// first thing - only NOW we can set ServletContext's class loader! It affects many things, including
2653-
// the TCCL used for example by javax.el.ExpressionFactory.newInstance()
2653+
// the TCCL used for example by jakarta.el.ExpressionFactory.newInstance()
26542654
if (highestRankedContext.getClassLoader() != null) {
26552655
deployment.setClassLoader(highestRankedContext.getClassLoader());
26562656
}
@@ -2928,7 +2928,7 @@ public String rewriteUrl(String originalUrl, String sessionId) {
29282928

29292929
manager = servletContainer.addDeployment(deployment);
29302930

2931-
// here's where Undertow-specific instance of javax.servlet.ServletContext is created
2931+
// here's where Undertow-specific instance of jakarta.servlet.ServletContext is created
29322932
manager.deploy();
29332933

29342934
HttpHandler handler = manager.start();

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/web/DefaultServlet.java

+8-19
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,19 @@
2121
import java.io.File;
2222
import java.io.FileNotFoundException;
2323
import java.io.IOException;
24-
import java.security.AccessController;
25-
import java.security.PrivilegedAction;
2624
import java.util.Arrays;
2725
import java.util.Collections;
2826
import java.util.Date;
2927
import java.util.HashSet;
3028
import java.util.Map;
3129
import java.util.Set;
32-
import javax.servlet.DispatcherType;
33-
import javax.servlet.RequestDispatcher;
34-
import javax.servlet.ServletConfig;
35-
import javax.servlet.ServletException;
36-
import javax.servlet.http.HttpServlet;
37-
import javax.servlet.http.HttpServletRequest;
38-
import javax.servlet.http.HttpServletResponse;
30+
import jakarta.servlet.DispatcherType;
31+
import jakarta.servlet.RequestDispatcher;
32+
import jakarta.servlet.ServletConfig;
33+
import jakarta.servlet.ServletException;
34+
import jakarta.servlet.http.HttpServlet;
35+
import jakarta.servlet.http.HttpServletRequest;
36+
import jakarta.servlet.http.HttpServletResponse;
3937

4038
import io.undertow.io.IoCallback;
4139
import io.undertow.io.Sender;
@@ -485,16 +483,7 @@ private boolean isAllowed(String path, DispatcherType dispatcherType) {
485483
}
486484

487485
protected static ServletRequestContext requireCurrentServletRequestContext() {
488-
if (System.getSecurityManager() == null) {
489-
return ServletRequestContext.requireCurrent();
490-
} else {
491-
return AccessController.doPrivileged(new PrivilegedAction<ServletRequestContext>() {
492-
@Override
493-
public ServletRequestContext run() {
494-
return ServletRequestContext.requireCurrent();
495-
}
496-
});
497-
}
486+
return ServletRequestContext.requireCurrent();
498487
}
499488

500489
}

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/web/FlexibleDeployment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323
import java.util.concurrent.Executor;
24-
import javax.servlet.ServletContext;
24+
import jakarta.servlet.ServletContext;
2525

2626
import io.undertow.security.api.AuthenticationMechanism;
2727
import io.undertow.server.HttpHandler;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/web/OsgiResourceManager.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
import java.net.URL;
2424
import java.nio.file.Path;
2525
import java.nio.file.Paths;
26-
import javax.servlet.ServletContext;
26+
import jakarta.servlet.ServletContext;
2727

2828
import io.undertow.server.handlers.resource.PathResource;
2929
import io.undertow.server.handlers.resource.PathResourceManager;
3030
import io.undertow.server.handlers.resource.Resource;
3131
import io.undertow.server.handlers.resource.ResourceChangeListener;
3232
import io.undertow.server.handlers.resource.ResourceManager;
3333
import io.undertow.server.handlers.resource.URLResource;
34-
import org.osgi.service.http.HttpContext;
34+
import org.ops4j.pax.web.service.http.HttpContext;
3535
import org.slf4j.Logger;
3636
import org.slf4j.LoggerFactory;
3737

@@ -40,14 +40,14 @@ public class OsgiResourceManager implements ResourceManager {
4040
public static final Logger LOG = LoggerFactory.getLogger(OsgiResourceManager.class);
4141

4242
/**
43-
* The {@link javax.servlet.ServletContext} which (according to OSGi CMPN web specifications) should delegate
44-
* to {@link org.osgi.service.http.HttpContext} / {@link org.osgi.service.http.context.ServletContextHelper}.
43+
* The {@link jakarta.servlet.ServletContext} which (according to OSGi CMPN web specifications) should delegate
44+
* to {@link org.ops4j.pax.web.service.http.HttpContext} / {@link org.osgi.service.servlet.context.ServletContextHelper}.
4545
*/
4646
private final ServletContext osgiScopedServletContext;
4747

4848
/**
49-
* 2nd parameter of {@link org.osgi.service.http.HttpService#registerResources(String, String, HttpContext)}
50-
* or {@link org.osgi.service.http.whiteboard.HttpWhiteboardConstants#HTTP_WHITEBOARD_RESOURCE_PREFIX}
49+
* 2nd parameter of {@link org.ops4j.pax.web.service.http.HttpService#registerResources(String, String, HttpContext)}
50+
* or {@link org.osgi.service.servlet.whiteboard.HttpWhiteboardConstants#HTTP_WHITEBOARD_RESOURCE_PREFIX}
5151
*/
5252
private final String chroot;
5353

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/web/OsgiServletContainerInitializerInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.ops4j.pax.web.service.undertow.internal.web;
1717

18-
import javax.servlet.ServletContainerInitializer;
18+
import jakarta.servlet.ServletContainerInitializer;
1919

2020
import io.undertow.servlet.api.InstanceFactory;
2121
import io.undertow.servlet.api.InstanceHandle;

‎pax-web-undertow/src/main/java/org/ops4j/pax/web/service/undertow/internal/web/UndertowResourceServlet.java

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import java.io.IOException;
2020
import java.nio.file.Paths;
2121
import java.util.Enumeration;
22-
import javax.servlet.DispatcherType;
23-
import javax.servlet.RequestDispatcher;
24-
import javax.servlet.ServletConfig;
25-
import javax.servlet.ServletContext;
26-
import javax.servlet.ServletException;
27-
import javax.servlet.http.HttpServletRequest;
28-
import javax.servlet.http.HttpServletResponse;
22+
import jakarta.servlet.DispatcherType;
23+
import jakarta.servlet.RequestDispatcher;
24+
import jakarta.servlet.ServletConfig;
25+
import jakarta.servlet.ServletContext;
26+
import jakarta.servlet.ServletException;
27+
import jakarta.servlet.http.HttpServletRequest;
28+
import jakarta.servlet.http.HttpServletResponse;
2929

3030
import io.undertow.server.HttpServerExchange;
3131
import io.undertow.server.handlers.cache.DirectBufferCache;
@@ -46,7 +46,7 @@
4646
*
4747
* <p>Due to caching infrastructure of Undertow, we need this servlet to implement {@link ResourceManager}, because
4848
* {@link io.undertow.server.handlers.resource.CachingResourceManager} should be created up front. The details
49-
* of {@link ResourceManager} will be set up in {@link javax.servlet.Servlet#init(ServletConfig)}.</p>
49+
* of {@link ResourceManager} will be set up in {@link jakarta.servlet.Servlet#init(ServletConfig)}.</p>
5050
*
5151
* <p>This servlet extends forked version of oroginal {@link io.undertow.servlet.handlers.DefaultServlet} and
5252
* is implemented as if the original version was more extensible. After forking I could implement everything
@@ -64,11 +64,11 @@ public class UndertowResourceServlet extends DefaultServlet implements ResourceM
6464

6565
/**
6666
* If {@link #baseDirectory} is not specified, this is resource prefix to prepend when calling
67-
* {@link org.osgi.service.http.context.ServletContextHelper#getResource(String)}
67+
* {@link org.osgi.service.servlet.context.ServletContextHelper#getResource(String)}
6868
*/
6969
private final String chroot;
7070

71-
/** The real {@link ResourceManager} configured in {@link javax.servlet.Servlet#init(ServletConfig)} */
71+
/** The real {@link ResourceManager} configured in {@link jakarta.servlet.Servlet#init(ServletConfig)} */
7272
private ResourceManager resourceManager;
7373

7474
private String[] welcomeFiles;
@@ -338,7 +338,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
338338
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
339339
// https://github.com/ops4j/org.ops4j.pax.web/issues/1664
340340
//
341-
// instead of relying on reflection used in javax.servlet.http.HttpServlet.doOptions()
341+
// instead of relying on reflection used in jakarta.servlet.http.HttpServlet.doOptions()
342342
// we simply return fixed set of methods (to be compatible with Jetty and Tomcat)
343343
resp.setHeader("Allow", "OPTIONS, GET, HEAD, POST");
344344
}

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/configuration/model/ConfigurationParserTest.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.Map;
2020
import javax.xml.parsers.SAXParserFactory;
2121

22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323
import org.ops4j.pax.web.service.PaxWebConfig;
2424
import org.ops4j.pax.web.service.undertow.internal.configuration.ResolvingContentHandler;
2525
import org.ops4j.pax.web.service.undertow.internal.configuration.UnmarshallingContentHandler;
@@ -28,8 +28,7 @@
2828
import org.xml.sax.InputSource;
2929
import org.xml.sax.XMLReader;
3030

31-
import static org.hamcrest.CoreMatchers.equalTo;
32-
import static org.hamcrest.MatcherAssert.assertThat;
31+
import static org.assertj.core.api.Assertions.assertThat;
3332

3433
public class ConfigurationParserTest {
3534

@@ -59,13 +58,13 @@ public void model() throws Exception {
5958
cfg.init();
6059
LOG.info("Configuration: {}", cfg);
6160

62-
assertThat(cfg.getSocketBindings().get(0).getPort(), equalTo(8123));
63-
assertThat(cfg.getSocketBindings().get(0).getName(), equalTo("http"));
64-
assertThat(cfg.getSocketBindings().get(1).getPort(), equalTo(8423));
65-
assertThat(cfg.getSocketBindings().get(1).getName(), equalTo("https"));
61+
assertThat(cfg.getSocketBindings().get(0).getPort()).isEqualTo(8123);
62+
assertThat(cfg.getSocketBindings().get(0).getName()).isEqualTo("http");
63+
assertThat(cfg.getSocketBindings().get(1).getPort()).isEqualTo(8423);
64+
assertThat(cfg.getSocketBindings().get(1).getName()).isEqualTo("https");
6665

67-
assertThat(cfg.getSecurityRealms().get(1).getIdentities().getSsl().getKeystore().getPath(),
68-
equalTo("/data/tmp/certs/server.keystore"));
66+
assertThat(cfg.getSecurityRealms().get(1).getIdentities().getSsl().getKeystore().getPath())
67+
.isEqualTo("/data/tmp/certs/server.keystore");
6968
}
7069

7170
}

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/EmbeddedUndertowHttp2Test.java

+16-18
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
import java.util.concurrent.ExecutorService;
3535
import java.util.concurrent.Executors;
3636
import java.util.concurrent.atomic.AtomicInteger;
37-
import javax.servlet.http.HttpServlet;
38-
import javax.servlet.http.HttpServletRequest;
39-
import javax.servlet.http.HttpServletResponse;
40-
import javax.servlet.http.PushBuilder;
37+
import jakarta.servlet.http.HttpServlet;
38+
import jakarta.servlet.http.HttpServletRequest;
39+
import jakarta.servlet.http.HttpServletResponse;
40+
import jakarta.servlet.http.PushBuilder;
4141

4242
import io.undertow.Handlers;
4343
import io.undertow.Undertow;
@@ -56,14 +56,12 @@
5656
import io.undertow.servlet.util.ImmediateInstanceFactory;
5757
import io.undertow.util.HeaderMap;
5858
import io.undertow.util.Headers;
59-
import org.junit.Before;
60-
import org.junit.Test;
59+
import org.junit.jupiter.api.BeforeEach;
60+
import org.junit.jupiter.api.Test;
6161
import org.slf4j.Logger;
6262
import org.slf4j.LoggerFactory;
6363

64-
import static org.hamcrest.CoreMatchers.equalTo;
65-
import static org.hamcrest.CoreMatchers.startsWith;
66-
import static org.hamcrest.MatcherAssert.assertThat;
64+
import static org.assertj.core.api.Assertions.assertThat;
6765

6866
public class EmbeddedUndertowHttp2Test {
6967

@@ -75,7 +73,7 @@ public class EmbeddedUndertowHttp2Test {
7573
private HpackDecoder decoder;
7674
private Map<Integer, String> responses;
7775

78-
@Before
76+
@BeforeEach
7977
public void resetState() {
8078
decoder = new HpackDecoder();
8179
responses = new HashMap<>();
@@ -392,7 +390,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
392390
response = response.substring(0, rnrn + 4);
393391
}
394392
LOG.info("Response\n{}", response);
395-
assertThat(fullResponse, startsWith("HTTP/1.1 101 Switching Protocols\r\n"));
393+
assertThat(fullResponse).startsWith("HTTP/1.1 101 Switching Protocols\r\n");
396394
buffer.position(rnrn + 4);
397395
boolean remains = true;
398396
while (remains) {
@@ -449,9 +447,9 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
449447
server.stop();
450448

451449
// indexed by HTTP/2 Stream ID
452-
assertThat(responses.get(1), equalTo("OK\n"));
453-
assertThat(responses.get(2), equalTo("body { margin: 0 }\n"));
454-
assertThat(responses.get(4), equalTo("window.alert(\"hello world\");\n"));
450+
assertThat(responses.get(1)).isEqualTo("OK\n");
451+
assertThat(responses.get(2)).isEqualTo("body { margin: 0 }\n");
452+
assertThat(responses.get(4)).isEqualTo("window.alert(\"hello world\");\n");
455453
}
456454

457455
@Test
@@ -660,9 +658,9 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
660658
server.stop();
661659

662660
// indexed by HTTP/2 Stream ID
663-
assertThat(responses.get(1), equalTo("OK\n"));
664-
assertThat(responses.get(2), equalTo("body { margin: 0 }\n"));
665-
assertThat(responses.get(4), equalTo("window.alert(\"hello world\");\n"));
661+
assertThat(responses.get(1)).isEqualTo("OK\n");
662+
assertThat(responses.get(2)).isEqualTo("body { margin: 0 }\n");
663+
assertThat(responses.get(4)).isEqualTo("window.alert(\"hello world\");\n");
666664
}
667665

668666
private void send(Selector selector, SelectionKey key, ByteBuffer buffer) throws IOException {
@@ -743,7 +741,7 @@ private boolean decodeFrame(ByteBuffer buffer, boolean incoming) throws IOExcept
743741
byte[] payload = new byte[length];
744742
int read = dis.read(payload, 0, length);
745743
if (read >= 0) {
746-
assertThat(read, equalTo(length));
744+
assertThat(read).isEqualTo(length);
747745
}
748746
buffer.position(buffer.position() + 3 + 1 + 1 + 4 + length);
749747

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/EmbeddedUndertowHttps2Test.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
import javax.net.ssl.SSLContext;
3030
import javax.net.ssl.SSLSession;
3131
import javax.net.ssl.TrustManagerFactory;
32-
import javax.servlet.http.HttpServlet;
33-
import javax.servlet.http.HttpServletRequest;
34-
import javax.servlet.http.HttpServletResponse;
35-
import javax.servlet.http.PushBuilder;
32+
import jakarta.servlet.http.HttpServlet;
33+
import jakarta.servlet.http.HttpServletRequest;
34+
import jakarta.servlet.http.HttpServletResponse;
35+
import jakarta.servlet.http.PushBuilder;
3636

3737
import io.undertow.Handlers;
3838
import io.undertow.Undertow;
@@ -74,13 +74,13 @@
7474
import org.apache.hc.core5.http2.HttpVersionPolicy;
7575
import org.apache.hc.core5.http2.config.H2Config;
7676
import org.apache.hc.core5.io.CloseMode;
77-
import org.junit.Test;
77+
import org.junit.jupiter.api.Test;
7878
import org.slf4j.Logger;
7979
import org.slf4j.LoggerFactory;
8080
import org.xnio.Options;
8181
import org.xnio.Sequence;
8282

83-
import static org.junit.Assert.assertTrue;
83+
import static org.junit.jupiter.api.Assertions.assertTrue;
8484

8585
public class EmbeddedUndertowHttps2Test {
8686

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/EmbeddedUndertowTest.java

+40-41
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
import java.util.List;
3030
import java.util.Map;
3131
import java.util.Set;
32-
import javax.servlet.DispatcherType;
33-
import javax.servlet.Filter;
34-
import javax.servlet.FilterChain;
35-
import javax.servlet.ServletConfig;
36-
import javax.servlet.ServletContainerInitializer;
37-
import javax.servlet.ServletContext;
38-
import javax.servlet.ServletContextEvent;
39-
import javax.servlet.ServletContextListener;
40-
import javax.servlet.ServletException;
41-
import javax.servlet.http.HttpFilter;
42-
import javax.servlet.http.HttpServlet;
43-
import javax.servlet.http.HttpServletRequest;
44-
import javax.servlet.http.HttpServletResponse;
32+
import jakarta.servlet.DispatcherType;
33+
import jakarta.servlet.Filter;
34+
import jakarta.servlet.FilterChain;
35+
import jakarta.servlet.ServletConfig;
36+
import jakarta.servlet.ServletContainerInitializer;
37+
import jakarta.servlet.ServletContext;
38+
import jakarta.servlet.ServletContextEvent;
39+
import jakarta.servlet.ServletContextListener;
40+
import jakarta.servlet.ServletException;
41+
import jakarta.servlet.http.HttpFilter;
42+
import jakarta.servlet.http.HttpServlet;
43+
import jakarta.servlet.http.HttpServletRequest;
44+
import jakarta.servlet.http.HttpServletResponse;
4545

4646
import io.undertow.Handlers;
4747
import io.undertow.Undertow;
@@ -70,7 +70,7 @@
7070
import io.undertow.servlet.util.ImmediateInstanceFactory;
7171
import io.undertow.util.ETag;
7272
import io.undertow.util.StatusCodes;
73-
import org.junit.Test;
73+
import org.junit.jupiter.api.Test;
7474
import org.slf4j.Logger;
7575
import org.slf4j.LoggerFactory;
7676
import org.xnio.ChannelListener;
@@ -83,10 +83,9 @@
8383
import org.xnio.XnioWorker;
8484
import org.xnio.channels.AcceptingChannel;
8585

86-
import static org.hamcrest.CoreMatchers.equalTo;
87-
import static org.hamcrest.MatcherAssert.assertThat;
88-
import static org.junit.Assert.assertFalse;
89-
import static org.junit.Assert.assertTrue;
86+
import static org.assertj.core.api.Assertions.assertThat;
87+
import static org.junit.jupiter.api.Assertions.assertFalse;
88+
import static org.junit.jupiter.api.Assertions.assertTrue;
9089

9190
public class EmbeddedUndertowTest {
9291

@@ -102,7 +101,7 @@ public void undertowWithSingleContextAndServlet() throws Exception {
102101

103102
HttpServlet servletInstance = new HttpServlet() {
104103
@Override
105-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
104+
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
106105
LOG.info("Handling request: {}", req.toString());
107106
resp.setContentType("text/plain");
108107
resp.setCharacterEncoding("UTF-8");
@@ -113,7 +112,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
113112
}
114113
};
115114

116-
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
115+
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
117116
servlet.addMapping("/s1/*");
118117

119118
DeploymentInfo deploymentInfo = Servlets.deployment()
@@ -160,7 +159,7 @@ public void embeddedServerWithUndertowResourceServlet() throws Exception {
160159

161160
HttpServlet servletInstance = new DefaultServlet();
162161

163-
ServletInfo servlet = Servlets.servlet("default", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
162+
ServletInfo servlet = Servlets.servlet("default", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
164163
servlet.addInitParam("directory-listing", "true");
165164

166165
// with "/" mapping, io.undertow.servlet.handlers.ServletPathMatch is used with
@@ -231,7 +230,7 @@ public void dynamicListeners() throws Exception {
231230

232231
HttpServlet servletInstance = new HttpServlet() {
233232
@Override
234-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
233+
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
235234
LOG.info("Handling request: {}", req.toString());
236235
resp.setContentType("text/plain");
237236
resp.setCharacterEncoding("UTF-8");
@@ -251,7 +250,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
251250
}
252251
};
253252

254-
ServletInfo servlet = Servlets.servlet("default", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
253+
ServletInfo servlet = Servlets.servlet("default", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
255254
servlet.addMapping("/s1");
256255

257256
DeploymentInfo deploymentInfo = Servlets.deployment()
@@ -282,7 +281,7 @@ public void contextInitialized(ServletContextEvent sce) {
282281
.addServletContainerInitializer(new ServletContainerInitializerInfo(ServletContainerInitializer.class,
283282
new ImmediateInstanceFactory<ServletContainerInitializer>(new ServletContainerInitializer() {
284283
@Override
285-
public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
284+
public void onStartup(Set<Class<?>> c, ServletContext ctx) {
286285
// ServletContextListener added from SCI - this is real "programmatic listener"
287286
ctx.addListener(new ServletContextListener() {
288287
@Override
@@ -354,7 +353,7 @@ public void undertowWithRequestWrappers() throws Exception {
354353

355354
HttpServlet servletInstance = new HttpServlet() {
356355
@Override
357-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
356+
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
358357
LOG.info("Handling request: {}", req.toString());
359358
resp.setContentType("text/plain");
360359
resp.setCharacterEncoding("UTF-8");
@@ -372,7 +371,7 @@ protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterC
372371
}
373372
};
374373

375-
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
374+
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
376375
servlet.addMapping("/s1/*");
377376

378377
FilterInfo filter = Servlets.filter("f1", filterInstance.getClass(), new ImmediateInstanceFactory<>(filterInstance));
@@ -434,7 +433,7 @@ protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterC
434433
// "XNIO-1 task-1@2434" prio=5 tid=0x17 nid=NA runnable
435434
// java.lang.Thread.State: RUNNABLE
436435
// at org.ops4j.pax.web.service.undertow.internal.EmbeddedUndertowTest$2.service(EmbeddedUndertowTest.java:139)
437-
// at javax.servlet.http.HttpServlet.service(HttpServlet.java:590)
436+
// at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
438437
// at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
439438
// at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
440439
// at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
@@ -559,7 +558,7 @@ public void undertowUsingLowLevelBuilders() throws Exception {
559558

560559
HttpServlet servletInstance = new HttpServlet() {
561560
@Override
562-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
561+
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
563562
LOG.info("Handling request: {}", req.toString());
564563
resp.setContentType("text/plain");
565564
resp.setCharacterEncoding("UTF-8");
@@ -570,7 +569,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
570569
}
571570
};
572571

573-
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
572+
ServletInfo servlet = Servlets.servlet("s1", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
574573
servlet.addMapping("/s1/*");
575574

576575
DeploymentInfo deploymentInfo = Servlets.deployment()
@@ -606,7 +605,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
606605
response = send(port, "/c1/s2");
607606
assertTrue(response.contains("HTTP/1.1 404"));
608607

609-
ServletInfo servlet2 = Servlets.servlet("s2", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
608+
ServletInfo servlet2 = Servlets.servlet("s2", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
610609
servlet2.addMapping("/s2/*");
611610
// this is not necessary. Not even reasonable, because the deployment info is originally cloned inside
612611
// the deployment
@@ -963,7 +962,7 @@ public void init(ServletConfig config) throws ServletException {
963962
}
964963

965964
@Override
966-
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
965+
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
967966
LOG.info("Handling request: {}", req.toString());
968967
resp.setContentType("text/plain");
969968
resp.setCharacterEncoding("UTF-8");
@@ -983,11 +982,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
983982

984983
// another example of "info" like class. "servlet info" is added to "deployment info" (directly, not as clone)
985984
// which means "servlet is registered inside servlet context"
986-
ServletInfo servlet = Servlets.servlet("c1s1", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
985+
ServletInfo servlet = Servlets.servlet("c1s1", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
987986
servlet.addMapping("/s1/*");
988987

989988
// "deployment info" represents a full information about single "servlet context" which can simply be
990-
// treated as "JavaEE web application" with single context path
989+
// treated as "JakartaEE web application" with single context path
991990
// this info is in 1:1 relation with single web.xml descriptor
992991
DeploymentInfo deploymentInfo1 = Servlets.deployment()
993992
.setClassLoader(this.getClass().getClassLoader())
@@ -1011,15 +1010,15 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
10111010
// - returned as io.undertow.servlet.api.DeploymentManager object that controls the lifecycle of
10121011
// associated "physical deployment"
10131012
DeploymentManager dm1 = container.addDeployment(deploymentInfo1);
1014-
assertThat(dm1.getState(), equalTo(DeploymentManager.State.UNDEPLOYED));
1013+
assertThat(dm1.getState()).isEqualTo(DeploymentManager.State.UNDEPLOYED);
10151014

10161015
// "deploying" clones the already cloned "deployment info" again and turns it into "physical deployment"
10171016
// represented by io.undertow.servlet.api.Deployment, which allows read access to various aspects
10181017
// of "web application".
10191018
// the problem with Undertow is that while we can add new servlets to existing "deployment", we can't
10201019
// remove them...
10211020
// "deploy" does few important things:
1022-
// - creates instance of io.undertow.servlet.spec.ServletContextImpl (THE javax.servlet.ServletContext)
1021+
// - creates instance of io.undertow.servlet.spec.ServletContextImpl (THE jakarta.servlet.ServletContext)
10231022
// - creates instance of io.undertow.servlet.core.DeploymentImpl
10241023
// - prepares all the "web elements" by turning "info" into "physical representation" of e.g., servlet
10251024
// - e.g., io.undertow.servlet.api.ServletInfo is turned into io.undertow.servlet.core.ManagedServlet
@@ -1032,11 +1031,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
10321031
// - the final handler is put as io.undertow.servlet.core.DeploymentImpl.initialHandler and then
10331032
// returned from (as-is) io.undertow.servlet.api.DeploymentManager.start()
10341033
dm1.deploy();
1035-
assertThat(dm1.getState(), equalTo(DeploymentManager.State.DEPLOYED));
1034+
assertThat(dm1.getState()).isEqualTo(DeploymentManager.State.DEPLOYED);
10361035

10371036
// "start" starts all lifecycle objects (servlets, filters, listeners)
10381037
HttpHandler handler = dm1.start();
1039-
assertThat(dm1.getState(), equalTo(DeploymentManager.State.STARTED));
1038+
assertThat(dm1.getState()).isEqualTo(DeploymentManager.State.STARTED);
10401039

10411040
path.addPrefixPath("/c1", handler);
10421041

@@ -1056,7 +1055,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
10561055

10571056
// add new context
10581057

1059-
ServletInfo servlet2 = Servlets.servlet("c2s1", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
1058+
ServletInfo servlet2 = Servlets.servlet("c2s1", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
10601059
servlet2.addMapping("/s1/*");
10611060

10621061
DeploymentInfo deploymentInfo2 = Servlets.deployment()
@@ -1076,7 +1075,7 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
10761075

10771076
// add new servlet to existing context
10781077

1079-
ServletInfo servlet3 = Servlets.servlet("c1s2", servletInstance.getClass(), new ImmediateInstanceFactory<HttpServlet>(servletInstance));
1078+
ServletInfo servlet3 = Servlets.servlet("c1s2", servletInstance.getClass(), new ImmediateInstanceFactory<>(servletInstance));
10801079
servlet3.addMapping("/s2/*");
10811080

10821081
response = send(port, "/c1/s2");
@@ -1122,7 +1121,7 @@ private String send(int port, String request, String... headers) throws IOExcept
11221121
s.getOutputStream().write(("Connection: close\r\n\r\n").getBytes());
11231122

11241123
byte[] buf = new byte[64];
1125-
int read = -1;
1124+
int read;
11261125
StringWriter sw = new StringWriter();
11271126
while ((read = s.getInputStream().read(buf)) > 0) {
11281127
sw.append(new String(buf, 0, read));
@@ -1135,7 +1134,7 @@ private String send(int port, String request, String... headers) throws IOExcept
11351134
private Map<String, String> extractHeaders(String response) throws IOException {
11361135
Map<String, String> headers = new LinkedHashMap<>();
11371136
try (BufferedReader reader = new BufferedReader(new StringReader(response))) {
1138-
String line = null;
1137+
String line;
11391138
while ((line = reader.readLine()) != null) {
11401139
if (line.trim().equals("")) {
11411140
break;

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/PathTest.java

+18-19
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,31 @@
1515
*/
1616
package org.ops4j.pax.web.service.undertow.internal;
1717

18-
import org.junit.Test;
18+
import org.junit.jupiter.api.Test;
1919

2020
import static io.undertow.util.CanonicalPathUtils.canonicalize;
21-
import static org.hamcrest.CoreMatchers.equalTo;
22-
import static org.hamcrest.MatcherAssert.assertThat;
21+
import static org.assertj.core.api.Assertions.assertThat;
2322

2423
public class PathTest {
2524

2625
@Test
2726
public void securePaths() {
28-
assertThat(canonicalize(""), equalTo(""));
29-
assertThat(canonicalize("/"), equalTo("/"));
30-
assertThat(canonicalize("c:"), equalTo("c:"));
31-
assertThat(canonicalize("c:/"), equalTo("c:/"));
32-
assertThat(canonicalize("c:\\"), equalTo("c:\\"));
33-
assertThat(canonicalize("//"), equalTo("/")); // Jetty: "//"
34-
assertThat(canonicalize("."), equalTo(".")); // Jetty: ""
35-
assertThat(canonicalize(".."), equalTo("..")); // Jetty: null, meaning we go out of chroot
36-
assertThat(canonicalize("../.."), equalTo("..")); // Jetty: null, meaning we go out of chroot
37-
assertThat(canonicalize("./././././././."), equalTo(".")); // Jetty: ""
38-
assertThat(canonicalize("../../../../../etc/passwd"), equalTo("../etc/passwd")); // Jetty: null, meaning we go out of chroot
39-
assertThat(canonicalize("path1"), equalTo("path1"));
40-
assertThat(canonicalize("./path1"), equalTo("./path1")); // Jetty: "path1"
41-
assertThat(canonicalize("../path1"), equalTo("../path1")); // Jetty: null, meaning we go out of chroot
42-
assertThat(canonicalize("path1/path2"), equalTo("path1/path2"));
43-
assertThat(canonicalize("path1/../path2"), equalTo("path1/path2")); // Jetty: "path2"
27+
assertThat(canonicalize("")).isEqualTo("");
28+
assertThat(canonicalize("/")).isEqualTo("/");
29+
assertThat(canonicalize("c:")).isEqualTo("c:");
30+
assertThat(canonicalize("c:/")).isEqualTo("c:/");
31+
assertThat(canonicalize("c:\\")).isEqualTo("c:\\");
32+
assertThat(canonicalize("//")).isEqualTo("/"); // Jetty: "//"
33+
assertThat(canonicalize(".")).isEqualTo("."); // Jetty: ""
34+
assertThat(canonicalize("..")).isEqualTo(".."); // Jetty: null, meaning we go out of chroot
35+
assertThat(canonicalize("../..")).isEqualTo(".."); // Jetty: null, meaning we go out of chroot
36+
assertThat(canonicalize("./././././././.")).isEqualTo("."); // Jetty: ""
37+
assertThat(canonicalize("../../../../../etc/passwd")).isEqualTo("../etc/passwd"); // Jetty: null, meaning we go out of chroot
38+
assertThat(canonicalize("path1")).isEqualTo("path1");
39+
assertThat(canonicalize("./path1")).isEqualTo("./path1"); // Jetty: "path1"
40+
assertThat(canonicalize("../path1")).isEqualTo("../path1"); // Jetty: null, meaning we go out of chroot
41+
assertThat(canonicalize("path1/path2")).isEqualTo("path1/path2");
42+
assertThat(canonicalize("path1/../path2")).isEqualTo("path1/path2"); // Jetty: "path2"
4443
}
4544

4645
}

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/UnifiedUndertowTest.java

+99-101
Large diffs are not rendered by default.

‎pax-web-undertow/src/test/java/org/ops4j/pax/web/service/undertow/internal/configuration/PredicateParserTest.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,25 @@
2121
import io.undertow.server.HandlerWrapper;
2222
import io.undertow.server.handlers.IPAddressAccessControlHandler;
2323
import io.undertow.server.handlers.builder.HandlerParser;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

26-
import static org.hamcrest.CoreMatchers.equalTo;
27-
import static org.hamcrest.MatcherAssert.assertThat;
28-
import static org.junit.Assert.assertNotNull;
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
import static org.junit.jupiter.api.Assertions.assertNotNull;
2928

3029
public class PredicateParserTest {
3130

3231
@Test
3332
public void parseExpression() {
3433
HandlerWrapper wrapper = HandlerParser.parse("ip-access-control(default-allow=false, acl={'127.0.0.1 allow', '127.0.0.2 allow'})", this.getClass().getClassLoader());
3534
assertNotNull(wrapper);
36-
assertThat(wrapper.wrap(null).getClass(), equalTo(IPAddressAccessControlHandler.class));
35+
assertThat(wrapper.wrap(null).getClass()).isEqualTo(IPAddressAccessControlHandler.class);
3736
}
3837

3938
@Test
4039
public void parsePredicate() {
4140
Predicate predicate = Predicates.parse("path-prefix('/cxf')", this.getClass().getClassLoader());
4241
assertNotNull(predicate);
43-
assertThat(predicate.getClass(), equalTo(PathPrefixPredicate.class));
42+
assertThat(predicate.getClass()).isEqualTo(PathPrefixPredicate.class);
4443
}
4544

4645
}

0 commit comments

Comments
 (0)
Please sign in to comment.