From 407f6d005acabf372b336eda08cf0959d3f70454 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 8 Apr 2020 11:03:36 +0200 Subject: [PATCH 1/2] Use HandlerList instead of HandlerCollection Signed-off-by: Greg Wilkins --- .../eclipse/jetty/embedded/LikeJettyXml.java | 4 +- .../src/main/resources/jetty-otherserver.xml | 2 +- jetty-deploy/src/test/resources/jetty.xml | 2 +- .../src/test/resources/embedder-jetty.xml | 2 +- .../jetty-osgi-boot/jettyhome/etc/jetty.xml | 5 +- .../config/etc/jetty-with-custom-class.xml | 5 +- .../src/test/config/etc/jetty.xml | 5 +- .../src/main/config/etc/jetty-rewrite.xml | 37 +- .../config/modules/rewrite/rewrite-rules.xml | 40 +- .../jetty/rewrite/handler/RewriteHandler.java | 32 +- .../jetty-rewrite.xml | 503 +++++++++--------- jetty-server/src/main/config/etc/jetty.xml | 12 +- .../jetty/server/handler/DefaultHandler.java | 2 +- .../jetty/servlet/ServletRequestLogTest.java | 10 +- .../src/main/config/etc/jetty-spring.xml | 2 +- .../org/eclipse/jetty/spring/jetty.xml | 2 +- .../src/test/resources/DefaultHandler.xml | 4 +- .../src/test/resources/RFC2616Base.xml | 6 +- .../src/test/resources/basic-server.xml | 2 +- 19 files changed, 336 insertions(+), 341 deletions(-) diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index ea16f69c68b6..b01bddfc8060 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -51,7 +51,7 @@ import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.StatisticsHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -105,7 +105,7 @@ public static Server createServer(int port, int securePort, boolean addDebugList // httpConfig.addCustomizer(new ForwardedRequestCustomizer()); // Handler Structure - HandlerCollection handlers = new HandlerCollection(); + HandlerList handlers = new HandlerList(); ContextHandlerCollection contexts = new ContextHandlerCollection(); handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()}); server.setHandler(handlers); diff --git a/examples/embedded/src/main/resources/jetty-otherserver.xml b/examples/embedded/src/main/resources/jetty-otherserver.xml index 895963070696..2a4c4d361c4d 100644 --- a/examples/embedded/src/main/resources/jetty-otherserver.xml +++ b/examples/embedded/src/main/resources/jetty-otherserver.xml @@ -3,7 +3,7 @@ - + diff --git a/jetty-deploy/src/test/resources/jetty.xml b/jetty-deploy/src/test/resources/jetty.xml index 7901921d3623..f3ada0bf854e 100644 --- a/jetty-deploy/src/test/resources/jetty.xml +++ b/jetty-deploy/src/test/resources/jetty.xml @@ -106,7 +106,7 @@ - + diff --git a/jetty-maven-plugin/src/test/resources/embedder-jetty.xml b/jetty-maven-plugin/src/test/resources/embedder-jetty.xml index 85ae556bddae..a7ad2021f67b 100644 --- a/jetty-maven-plugin/src/test/resources/embedder-jetty.xml +++ b/jetty-maven-plugin/src/test/resources/embedder-jetty.xml @@ -3,7 +3,7 @@ - + diff --git a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml index d4bac27248f0..b73820e42e46 100644 --- a/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml +++ b/jetty-osgi/jetty-osgi-boot/jettyhome/etc/jetty.xml @@ -24,7 +24,7 @@ - + @@ -33,9 +33,6 @@ - - - diff --git a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-with-custom-class.xml b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-with-custom-class.xml index 6c2b9d68082e..4561574d2086 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-with-custom-class.xml +++ b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty-with-custom-class.xml @@ -26,7 +26,7 @@ - + @@ -35,9 +35,6 @@ - - - diff --git a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml index 25f831c57c54..1d10384859cc 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml +++ b/jetty-osgi/test-jetty-osgi/src/test/config/etc/jetty.xml @@ -24,7 +24,7 @@ - + @@ -33,9 +33,6 @@ - - - diff --git a/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml b/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml index 1dc494ce93f0..e123113c5c22 100644 --- a/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml +++ b/jetty-rewrite/src/main/config/etc/jetty-rewrite.xml @@ -1,5 +1,4 @@ - - + @@ -9,22 +8,28 @@ - - - - - - - - REQUEST - ASYNC - - + + + - - - + + + + + + REQUEST + + + + + ASYNC + + + + + + diff --git a/jetty-rewrite/src/main/config/modules/rewrite/rewrite-rules.xml b/jetty-rewrite/src/main/config/modules/rewrite/rewrite-rules.xml index 90e983f7b145..41be9bb71801 100644 --- a/jetty-rewrite/src/main/config/modules/rewrite/rewrite-rules.xml +++ b/jetty-rewrite/src/main/config/modules/rewrite/rewrite-rules.xml @@ -14,10 +14,10 @@ - /favicon.ico - Cache-Control - Max-Age=3600,public - true + /favicon.ico + Cache-Control + Max-Age=3600,public + true @@ -27,8 +27,8 @@ - /test/rewrite/ - /test/rewrite/info.html + /test/rewrite/ + /test/rewrite/info.html @@ -38,8 +38,8 @@ - /test/some/old/context - /test/rewritten/newcontext + /test/some/old/context + /test/rewritten/newcontext @@ -49,8 +49,8 @@ - /test/rewrite/for/* - /test/rewritten/ + /test/rewrite/for/* + /test/rewritten/ @@ -60,8 +60,8 @@ - (.*?)/reverse/([^/]*)/(.*) - $1/reverse/$3/$2 + (.*?)/reverse/([^/]*)/(.*) + $1/reverse/$3/$2 @@ -71,9 +71,9 @@ - /* - visited - yes + /* + visited + yes @@ -83,8 +83,8 @@ - /test/redirect/* - /test/redirected + /test/redirect/* + /test/redirected @@ -94,9 +94,9 @@ - /400Error - 400 - ResponsePatternRule Demo + /400Error + 400 + ResponsePatternRule Demo diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java index 81db59e94577..a3e0f8bf7acd 100644 --- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java +++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RewriteHandler.java @@ -146,24 +146,22 @@ * </New> * * <Set name="handler"> - * <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> - * <Set name="handlers"> - * <Array type="org.eclipse.jetty.server.Handler"> - * <Item> - * <Ref id="RewriteHandler"/> - * </Item> - * <Item> - * <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> - * </Item> - * <Item> - * <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> - * </Item> - * <Item> - * <New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/> - * </Item> - * </Array> + * <Ref id="RewriteHandler"/> + * <Set name="handler"> + * <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> + * <Set name="handlers"> + * <Array type="org.eclipse.jetty.server.Handler"> + * <Item> + * <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> + * </Item> + * <Item> + * <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> + * </Item> + * </Array> + * </Set> + * </New> * </Set> - * </New> + * </Ref> * </Set> * */ diff --git a/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml b/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml index dedac35bc327..2688e21964cc 100644 --- a/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml +++ b/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml @@ -1,5 +1,4 @@ - - + @@ -9,263 +8,269 @@ - - - - - - - - 10 - 50 - 5 - 2 + + + + + + + 10 + 50 + 5 + 2 + + + + + + + + + + + + + + + + + + 30000 - - - - - - - - - - - - - - - 30000 - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + requestedPath + true + + + + + + + /* + /test + + + + + + /session/ + 401 + Setting error code 401 + + + + + + *.jsp + Server + dexter webserver + + + + + + *.jsp + title + driven header purpose + + + + + + /test/dispatch + http://jetty.eclipse.org + + + + + + /test-jaas/$ + /demo + + + + + + X-Forwarded-Scheme + https + https + + + + + + + + + eclipse.com + www.eclipse.com + eclipse.org + www.eclipse.org + + + + + + + /* + CookiePatternRule + 1 + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + /contexts + + 1 - - --> - - - - - - - - - - - - requestedPath - true - - - - - - - /* - /test - - - - - - /session/ - 401 - Setting error code 401 - - - - - - *.jsp - Server - dexter webserver - - - - - - *.jsp - title - driven header purpose - - - - - - /test/dispatch - http://jetty.eclipse.org - - - - - - /test-jaas/$ - /demo - - - - - - X-Forwarded-Scheme - https - https - - - - - - - - - eclipse.com - www.eclipse.com - eclipse.org - www.eclipse.org - - - - - - - /* - CookiePatternRule - 1 - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + /webapps + + false + true + false + /etc/webdefault.xml - - - - - - - - - - - - - - - - - - /contexts - 1 + + + + + + + + + + + + + + + Test Realm + /etc/realm.properties + - - - - - - - - - - - - - - - - - - - - - /webapps - false - true - false - /etc/webdefault.xml - - - - - - - - - - - - - - - - Test Realm - /etc/realm.properties - - - + + + + + + + + + + + + + + + /yyyy_mm_dd.request.log + + yyyy_MM_dd + 90 + true + true + false + GMT + + - - - - - - - - - - - /yyyy_mm_dd.request.log - yyyy_MM_dd - 90 - true - true - false - GMT - - - - - - - - true - 1000 + + + + true + 1000 diff --git a/jetty-server/src/main/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml index 0c6f3b4d948d..cf4e989eee52 100644 --- a/jetty-server/src/main/config/etc/jetty.xml +++ b/jetty-server/src/main/config/etc/jetty.xml @@ -78,17 +78,13 @@ - + - - - - - - + + - + diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java index 67c7c1b3efbf..48390157fafb 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java @@ -85,7 +85,7 @@ public DefaultHandler() @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - if (response.isCommitted() || baseRequest.isHandled()) + if (response.isCommitted() || baseRequest.isAsyncStarted()) return; baseRequest.setHandled(true); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java index 0965236b8a42..a462e89b6a3f 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java @@ -47,7 +47,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.ErrorHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.junit.jupiter.api.Assertions; @@ -301,7 +301,7 @@ public void testLogHandlerCollection(Servlet testServlet, String requestPath, St // First the behavior as defined in etc/jetty.xml // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); + HandlerList handlers = new HandlerList(); // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); // id="DefaultHandler" @@ -391,7 +391,7 @@ public void testLogHandlerCollectionErrorHandlerServerBean(Servlet testServlet, // First the behavior as defined in etc/jetty.xml // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); + HandlerList handlers = new HandlerList(); // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); // id="DefaultHandler" @@ -479,7 +479,7 @@ public void testLogHandlerCollectionSimpleErrorPageMapping(Servlet testServlet, // First the behavior as defined in etc/jetty.xml // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); + HandlerList handlers = new HandlerList(); // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); // id="DefaultHandler" @@ -572,7 +572,7 @@ public void testLogHandlerWrapped(Servlet testServlet, String requestPath, Strin // First the behavior as defined in etc/jetty.xml (as is) // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); + HandlerList handlers = new HandlerList(); // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); // id="DefaultHandler" diff --git a/jetty-spring/src/main/config/etc/jetty-spring.xml b/jetty-spring/src/main/config/etc/jetty-spring.xml index 637450d51a78..40a5e7cf1bb4 100644 --- a/jetty-spring/src/main/config/etc/jetty-spring.xml +++ b/jetty-spring/src/main/config/etc/jetty-spring.xml @@ -29,7 +29,7 @@ - + diff --git a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml index 28915187ad8c..57b87cc407b9 100644 --- a/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml +++ b/jetty-spring/src/test/resources/org/eclipse/jetty/spring/jetty.xml @@ -21,7 +21,7 @@ - + diff --git a/tests/test-integration/src/test/resources/DefaultHandler.xml b/tests/test-integration/src/test/resources/DefaultHandler.xml index 992bea972259..e23d89e6d0e7 100644 --- a/tests/test-integration/src/test/resources/DefaultHandler.xml +++ b/tests/test-integration/src/test/resources/DefaultHandler.xml @@ -20,11 +20,11 @@ - + - + diff --git a/tests/test-integration/src/test/resources/RFC2616Base.xml b/tests/test-integration/src/test/resources/RFC2616Base.xml index ed55b90a72db..aad3e838d43a 100644 --- a/tests/test-integration/src/test/resources/RFC2616Base.xml +++ b/tests/test-integration/src/test/resources/RFC2616Base.xml @@ -33,7 +33,7 @@ - + @@ -48,7 +48,7 @@ /virtualhost - + virtual @@ -56,7 +56,7 @@ /tests /default - + default diff --git a/tests/test-integration/src/test/resources/basic-server.xml b/tests/test-integration/src/test/resources/basic-server.xml index fefca7e39e85..74283e416414 100644 --- a/tests/test-integration/src/test/resources/basic-server.xml +++ b/tests/test-integration/src/test/resources/basic-server.xml @@ -19,7 +19,7 @@ - + From 6367a8b9d954ab2c04a904e399e5bdb9931bc5a0 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 8 Apr 2020 15:07:11 +0200 Subject: [PATCH 2/2] Use HandlerList instead of HandlerCollection Signed-off-by: Greg Wilkins --- .../eclipse/jetty/embedded/ExampleServer.java | 7 +- .../jetty/embedded/FastFileServer.java | 8 +- .../eclipse/jetty/embedded/FileServer.java | 5 +- .../org/eclipse/jetty/embedded/JarServer.java | 5 +- .../eclipse/jetty/embedded/LikeJettyXml.java | 5 +- .../eclipse/jetty/embedded/ManyHandlers.java | 2 +- .../jetty/embedded/WebSocketJsrServer.java | 6 +- .../src/main/resources/exampleserver.xml | 2 +- .../eclipse/jetty/ant/ServerProxyImpl.java | 16 +-- .../jetty/deploy/BadAppDeployTest.java | 21 ++-- .../http/spi/JettyHttpServerProvider.java | 6 +- .../jetty/http/spi/util/SpiUtility.java | 110 ------------------ .../jetty/maven/plugin/ServerSupport.java | 17 +-- .../handler/CookiePatternRuleTest.java | 6 +- .../java/org/eclipse/jetty/runner/Runner.java | 3 +- .../jetty/security/AliasedConstraintTest.java | 5 +- .../jetty/server/handler/DefaultHandler.java | 2 +- .../jetty/server/PartialRFC2616Test.java | 8 +- .../jetty/server/ServerConnectorTest.java | 25 +--- .../handler/ContextHandlerCollectionTest.java | 3 +- .../server/handler/ContextHandlerTest.java | 7 +- .../server/handler/DefaultHandlerTest.java | 5 +- .../jetty/server/handler/HandlerTest.java | 69 ++++++----- .../server/handler/NcsaRequestLogTest.java | 6 +- .../handler/SecuredRedirectHandlerTest.java | 6 +- .../AsyncContextDispatchWithQueryStrings.java | 6 +- .../jetty/servlet/AsyncContextTest.java | 7 +- .../jetty/servlet/DefaultHandlerTest.java | 7 +- .../jetty/servlet/ServletRequestLogTest.java | 25 +--- .../jetty/servlet/ServletWrapperTest.java | 6 +- .../jetty/webapp/HugeResourceTest.java | 6 +- .../websocket/javax/tests/CoreServer.java | 5 +- .../javax/tests/RestartContextTest.java | 11 +- .../server/browser/BrowserDebugTool.java | 6 +- .../tests/client/BadNetworkTest.java | 5 +- .../tests/client/ClientCloseTest.java | 5 +- .../tests/client/ClientSessionsTest.java | 5 +- .../tests/client/SlowClientTest.java | 6 +- .../tests/server/FrameAnnotationTest.java | 6 +- .../tests/server/FrameListenerTest.java | 6 +- .../tests/server/PartialListenerTest.java | 6 +- .../tests/server/ServerCloseTest.java | 6 +- .../tests/server/SlowServerTest.java | 6 +- .../jetty/test/DeploymentErrorTest.java | 8 +- .../eclipse/jetty/test/DigestPostTest.java | 8 +- .../jetty/test/FailedSelectorTest.java | 6 +- .../jetty/DatabaseLoginServiceTestServer.java | 7 +- .../session/RequestDispatchedSessionTest.java | 6 +- .../java/org/eclipse/jetty/TestServer.java | 7 +- .../jetty/TestTransparentProxyServer.java | 9 +- 50 files changed, 116 insertions(+), 420 deletions(-) delete mode 100644 jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/util/SpiUtility.java diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ExampleServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ExampleServer.java index 1eed27836c61..538c06486fbf 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ExampleServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ExampleServer.java @@ -19,11 +19,10 @@ package org.eclipse.jetty.embedded; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.servlet.ServletContextHandler; public class ExampleServer @@ -41,9 +40,7 @@ public static Server createServer(int port) context.addServlet(HelloServlet.class, "/hello"); context.addServlet(AsyncEchoServlet.class, "/echo/*"); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[]{context, new DefaultHandler()}); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); return server; } diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FastFileServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FastFileServer.java index 2254cce0a698..745a551acd5c 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FastFileServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FastFileServer.java @@ -31,7 +31,6 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.MimeTypes; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpOutput; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; @@ -62,12 +61,9 @@ public static Server createServer(int port, File resourceBase) { Server server = new Server(port); - HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[]{ + server.setHandler(new HandlerList( new FastFileHandler(resourceBase), - new DefaultHandler() - }); - server.setHandler(handlers); + new DefaultHandler())); return server; } diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java index 58d32b93446e..fbff826fdd88 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java @@ -21,7 +21,6 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; @@ -53,9 +52,7 @@ public static Server createServer(int port, Resource baseResource) throws Except resourceHandler.setBaseResource(baseResource); // Add the ResourceHandler to the server. - HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[]{resourceHandler, new DefaultHandler()}); - server.setHandler(handlers); + server.setHandler(new HandlerList(resourceHandler, new DefaultHandler())); return server; } diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java index ca285e010ddd..b5b41164869a 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/JarServer.java @@ -51,10 +51,7 @@ public static Server createServer(int port) throws Exception context.setBaseResource(base); context.addServlet(new ServletHolder(new DefaultServlet()), "/"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); return server; } diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java index b01bddfc8060..b094964df537 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/LikeJettyXml.java @@ -40,7 +40,6 @@ import org.eclipse.jetty.server.AsyncRequestLogWriter; import org.eclipse.jetty.server.CustomRequestLog; import org.eclipse.jetty.server.DebugListener; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.LowResourceMonitor; @@ -105,10 +104,8 @@ public static Server createServer(int port, int securePort, boolean addDebugList // httpConfig.addCustomizer(new ForwardedRequestCustomizer()); // Handler Structure - HandlerList handlers = new HandlerList(); ContextHandlerCollection contexts = new ContextHandlerCollection(); - handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, new DefaultHandler())); // === jetty-jmx.xml === MBeanContainer mbContainer = new MBeanContainer( diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java index 77dd973eafe7..58df808147d8 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/ManyHandlers.java @@ -124,7 +124,7 @@ public static Server createServer(int port) throws IOException CustomRequestLog ncsaLog = new CustomRequestLog(requestLogFile.getAbsolutePath()); server.setRequestLog(ncsaLog); - // create the handler collections + // create the handlers list HandlerList handlers = new HandlerList(); // wrap contexts around specific handlers diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java index 86c88c703e35..26fa623cdbe8 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/WebSocketJsrServer.java @@ -50,11 +50,8 @@ public static Server createServer(int port) { Server server = new Server(port); - HandlerList handlers = new HandlerList(); - ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); - handlers.addHandler(context); // Enable javax.websocket configuration for the context JavaxWebSocketServletContainerInitializer.configure(context, @@ -65,8 +62,7 @@ public static Server createServer(int port) } ); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); return server; } diff --git a/examples/embedded/src/main/resources/exampleserver.xml b/examples/embedded/src/main/resources/exampleserver.xml index 138bdfd53b0e..b3940b8f20ac 100644 --- a/examples/embedded/src/main/resources/exampleserver.xml +++ b/examples/embedded/src/main/resources/exampleserver.xml @@ -25,7 +25,7 @@ - + diff --git a/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java b/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java index 16460fe7c18f..e71da97c6576 100644 --- a/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java +++ b/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java @@ -30,7 +30,6 @@ import org.eclipse.jetty.ant.utils.ServerProxy; import org.eclipse.jetty.ant.utils.TaskLog; import org.eclipse.jetty.security.LoginService; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -39,6 +38,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.util.Scanner; import org.eclipse.jetty.util.resource.PathResource; import org.eclipse.jetty.util.resource.Resource; @@ -406,23 +406,15 @@ private void configureHandlers() if (requestLog != null) server.setRequestLog(requestLog); - contexts = (ContextHandlerCollection)server - .getChildHandlerByClass(ContextHandlerCollection.class); + contexts = server.getChildHandlerByClass(ContextHandlerCollection.class); if (contexts == null) { contexts = new ContextHandlerCollection(); - HandlerCollection handlers = (HandlerCollection)server - .getChildHandlerByClass(HandlerCollection.class); + HandlerCollection handlers = server.getChildHandlerByClass(HandlerCollection.class); if (handlers == null) - { - handlers = new HandlerCollection(); - server.setHandler(handlers); - handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()}); - } + server.setHandler(new HandlerList(contexts, new DefaultHandler())); else - { handlers.addHandler(contexts); - } } //if there are any extra contexts to deploy diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BadAppDeployTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BadAppDeployTest.java index 0c99e06d673a..6a6ee4fb9d8a 100644 --- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BadAppDeployTest.java +++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/BadAppDeployTest.java @@ -29,7 +29,7 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.jupiter.WorkDir; @@ -69,7 +69,7 @@ public void testBadAppThrowOnUnavailableTrueXmlOrder() throws Exception It is important that this Order be maintained for an accurate test case. ### BEAN: QueuedThreadPool[qtp1327763628]@4f2410ac{STOPPED,8<=0<=200,i=0,r=-1,q=0}[NO_TRY] ### BEAN: ServerConnector@16f65612{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} - ### BEAN: HandlerCollection@5f150435{STOPPED} + ### BEAN: HandlerList@5f150435{STOPPED} ### BEAN: DeploymentManager@1c53fd30{STOPPED} */ @@ -79,10 +79,8 @@ public void testBadAppThrowOnUnavailableTrueXmlOrder() throws Exception server.addConnector(connector); ContextHandlerCollection contexts = new ContextHandlerCollection(); - HandlerCollection handlers = new HandlerCollection(); - handlers.addHandler(contexts); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); // this should be done before addBean(deploymentManager) + // this should be done before addBean(deploymentManager) + server.setHandler(new HandlerList(contexts, new DefaultHandler())); DeploymentManager deploymentManager = new DeploymentManager(); deploymentManager.setContexts(contexts); @@ -121,7 +119,7 @@ public void testBadAppThrowOnUnavailableTrueEmbeddedOrder() throws Exception ### BEAN: QueuedThreadPool[qtp1530388690]@5b37e0d2{STOPPED,8<=0<=200,i=0,r=-1,q=0}[NO_TRY] ### BEAN: ServerConnector@5e265ba4{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} ### BEAN: DeploymentManager@3419866c{STOPPED} - ### BEAN: HandlerCollection@63e31ee{STOPPED} + ### BEAN: HandlerList@63e31ee{STOPPED} */ server = new Server(); @@ -146,12 +144,11 @@ public void testBadAppThrowOnUnavailableTrueEmbeddedOrder() throws Exception webAppProvider.setMonitoredDirName(webappsDir.toString()); webAppProvider.setScanInterval(1); - server.addBean(deploymentManager); // this should be done before setHandler(handlers) + // this must be done before setHandler(handlers) + server.addBean(deploymentManager); - HandlerCollection handlers = new HandlerCollection(); - handlers.addHandler(contexts); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); // this should be done after addBean(deploymentManager) + // this must be done after addBean(deploymentManager) + server.setHandler(new HandlerList(contexts, new DefaultHandler())); assertTimeoutPreemptively(ofSeconds(10), () -> { diff --git a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java index 43ab5f8242ee..a9a875c84023 100644 --- a/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java +++ b/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java @@ -24,11 +24,10 @@ import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsServer; import com.sun.net.httpserver.spi.HttpServerProvider; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ThreadPool; @@ -57,8 +56,7 @@ public HttpServer createHttpServer(InetSocketAddress addr, int backlog) ThreadPool threadPool = new DelegatingThreadPool(new QueuedThreadPool()); server = new Server(threadPool); - HandlerCollection handlerCollection = new HandlerCollection(); - handlerCollection.setHandlers(new Handler[]{new ContextHandlerCollection(), new DefaultHandler()}); + HandlerList handlerCollection = new HandlerList(new ContextHandlerCollection(), new DefaultHandler()); server.setHandler(handlerCollection); shared = false; diff --git a/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/util/SpiUtility.java b/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/util/SpiUtility.java deleted file mode 100644 index 264a880cc251..000000000000 --- a/jetty-http-spi/src/test/java/org/eclipse/jetty/http/spi/util/SpiUtility.java +++ /dev/null @@ -1,110 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0 -// -// This Source Code may also be made available under the following -// Secondary Licenses when the conditions for such availability set -// forth in the Eclipse Public License, v. 2.0 are satisfied: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.http.spi.util; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.eclipse.jetty.http.spi.DelegatingThreadPool; -import org.eclipse.jetty.http.spi.JettyHttpServer; -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.server.handler.ContextHandlerCollection; -import org.eclipse.jetty.server.handler.HandlerCollection; - -/** - * This is a utility class. Test cases uses this utility class - */ -public class SpiUtility -{ - - public static ThreadPoolExecutor getThreadPoolExecutor(int poolSize, int[] poolInfo) - { - return new ThreadPoolExecutor(poolSize, poolInfo[0], poolInfo[1], TimeUnit.SECONDS, new ArrayBlockingQueue(poolInfo[2])); - } - - public static DelegatingThreadPool getDelegatingThreadPool() - { - ThreadPoolExecutor threadPoolExecutor = SpiUtility.getThreadPoolExecutor(Pool.CORE_POOL_SIZE.getValue(), SpiConstants.poolInfo); - DelegatingThreadPool delegatingThreadPool = new DelegatingThreadPool(threadPoolExecutor); - return delegatingThreadPool; - } - - public static InetSocketAddress getInetSocketAddress() - { - return new InetSocketAddress(SpiConstants.LOCAL_HOST, SpiConstants.DEFAULT_PORT); - } - - public static void callBind(JettyHttpServer jettyHttpServer) throws Exception - { - InetSocketAddress inetSocketAddress = SpiUtility.getInetSocketAddress(); - jettyHttpServer.bind(inetSocketAddress, SpiConstants.BACK_LOG); - } - - public static Server getServerForContextHandler() - { - Handler handler = new ContextHandler(); - Server server = new Server(); - server.setHandler(handler); - return server; - } - - public static Server getServerForContextHandlerCollection() - { - Handler handler = new ContextHandlerCollection(); - Server server = new Server(); - server.setHandler(handler); - return server; - } - - public static Server getServerForHandlerCollection() - { - ContextHandler handler = new ContextHandler(); - Handler[] handles = - {handler}; - HandlerCollection contextHandler = new HandlerCollection(); - contextHandler.setHandlers(handles); - Server server = new Server(); - server.setHandler(contextHandler); - return server; - } - - public static Map> getAcceptCharsetHeader() - { - ArrayList valueSet = new ArrayList(); - valueSet.add(SpiConstants.UTF_8); - Map> headers = new Hashtable<>(); - headers.put(SpiConstants.ACCEPT_CHARSET, valueSet); - return headers; - } - - public static List getReqHeaderValues() - { - List reqHeaderValues = new ArrayList<>(); - reqHeaderValues.add("en-US"); - return reqHeaderValues; - } -} diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java index b1001c744b40..95024bb85ea4 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/ServerSupport.java @@ -26,14 +26,13 @@ import org.eclipse.jetty.security.LoginService; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; -import org.eclipse.jetty.server.handler.RequestLogHandler; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.util.resource.PathResource; import org.eclipse.jetty.webapp.Configurations; import org.eclipse.jetty.webapp.WebAppContext; @@ -68,26 +67,18 @@ public static void configureHandlers(Server server, List context if (server == null) throw new IllegalArgumentException("Server is null"); - DefaultHandler defaultHandler = new DefaultHandler(); - RequestLogHandler requestLogHandler = new RequestLogHandler(); if (requestLog != null) - requestLogHandler.setRequestLog(requestLog); + server.setRequestLog(requestLog); ContextHandlerCollection contexts = findContextHandlerCollection(server); if (contexts == null) { contexts = new ContextHandlerCollection(); - HandlerCollection handlers = (HandlerCollection)server.getChildHandlerByClass(HandlerCollection.class); + HandlerCollection handlers = server.getChildHandlerByClass(HandlerCollection.class); if (handlers == null) - { - handlers = new HandlerCollection(); - server.setHandler(handlers); - handlers.setHandlers(new Handler[]{contexts, defaultHandler, requestLogHandler}); - } + server.setHandler(new HandlerList(contexts, new DefaultHandler())); else - { handlers.addHandler(contexts); - } } if (contextHandlers != null) diff --git a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java index 08253d96c50c..9fd364b8627c 100644 --- a/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java +++ b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java @@ -76,11 +76,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques } }; - HandlerList handlers = new HandlerList(); - handlers.addHandler(rewriteHandler); - handlers.addHandler(dummyHandler); - - server.setHandler(handlers); + server.setHandler(new HandlerList(rewriteHandler, dummyHandler)); server.start(); } diff --git a/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java b/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java index 0e67904d8f44..9b3ab625ca28 100644 --- a/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java +++ b/jetty-runner/src/main/java/org/eclipse/jetty/runner/Runner.java @@ -46,6 +46,7 @@ import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.StatisticsHandler; import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.servlet.ServletContextHandler; @@ -341,7 +342,7 @@ else if ("STOP.PORT".equals(sysProps[0])) HandlerCollection handlers = (HandlerCollection)_server.getChildHandlerByClass(HandlerCollection.class); if (handlers == null) { - handlers = new HandlerCollection(); + handlers = new HandlerList(); _server.setHandler(handlers); } diff --git a/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java b/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java index 413bebee3ec5..92d93d366d1b 100644 --- a/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java +++ b/jetty-security/src/test/java/org/eclipse/jetty/security/AliasedConstraintTest.java @@ -26,7 +26,6 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; @@ -81,9 +80,7 @@ public static void startServer() throws Exception context.setContextPath("/ctx"); context.setResourceBase(MavenTestingUtils.getTestResourceDir("docroot").getAbsolutePath()); - HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[]{context, new DefaultHandler()}); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); context.setHandler(session); // context.addAliasCheck(new AllowSymLinkAliasChecker()); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java index 48390157fafb..67c7c1b3efbf 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java @@ -85,7 +85,7 @@ public DefaultHandler() @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - if (response.isCommitted() || baseRequest.isAsyncStarted()) + if (response.isCommitted() || baseRequest.isHandled()) return; baseRequest.setHandled(true); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java b/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java index a45a8d91be28..52dd7d94c6b7 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java @@ -27,7 +27,7 @@ import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.LocalConnector.LocalEndPoint; import org.eclipse.jetty.server.handler.ContextHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -64,11 +64,7 @@ public void init() throws Exception context.setContextPath("/"); context.setHandler(new DumpHandler()); - HandlerCollection collection = new HandlerCollection(); - collection.setHandlers(new Handler[] - {vcontext, context}); - - server.setHandler(collection); + server.setHandler(new HandlerList(vcontext, context)); server.start(); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java index 11ce1879cc71..3fe424c20728 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ServerConnectorTest.java @@ -126,11 +126,7 @@ public void testReuseAddressDefault() throws Exception connector.setPort(0); server.addConnector(connector); - HandlerList handlers = new HandlerList(); - handlers.addHandler(new ReuseInfoHandler()); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(new ReuseInfoHandler(), new DefaultHandler())); try { @@ -162,11 +158,7 @@ public void testReuseAddressTrue() throws Exception connector.setReuseAddress(true); server.addConnector(connector); - HandlerList handlers = new HandlerList(); - handlers.addHandler(new ReuseInfoHandler()); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(new ReuseInfoHandler(), new DefaultHandler())); try { @@ -198,11 +190,7 @@ public void testReuseAddressFalse() throws Exception connector.setReuseAddress(false); server.addConnector(connector); - HandlerList handlers = new HandlerList(); - handlers.addHandler(new ReuseInfoHandler()); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(new ReuseInfoHandler(), new DefaultHandler())); try { @@ -312,12 +300,9 @@ public void testBindToAddressWhichIsInUse() throws Exception connector.setPort(port); server.addConnector(connector); - HandlerList handlers = new HandlerList(); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(new DefaultHandler())); - IOException x = assertThrows(IOException.class, () -> server.start()); + IOException x = assertThrows(IOException.class, server::start); assertThat(x.getCause(), instanceOf(BindException.class)); assertThat(x.getMessage(), containsString("0.0.0.0:" + port)); } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java index f9c05bed48ab..dd4ee094d0d3 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java @@ -352,12 +352,11 @@ public void testAsyncWrappedContext() throws Exception ContextHandler left = new ContextHandler("/left"); left.setHandler(new AsyncHandler("left")); - HandlerList centre = new HandlerList(); ContextHandler centreLeft = new ContextHandler("/leftcentre"); centreLeft.setHandler(new AsyncHandler("left of centre")); ContextHandler centreRight = new ContextHandler("/rightcentre"); centreRight.setHandler(new AsyncHandler("right of centre")); - centre.setHandlers(new Handler[]{centreLeft, new WrappedHandler(centreRight)}); + HandlerList centre = new HandlerList(centreLeft, new WrappedHandler(centreRight)); ContextHandler right = new ContextHandler("/right"); right.setHandler(new AsyncHandler("right")); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java index dbbc0d6e274b..598ceb868012 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerTest.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; - import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.http.HttpServletRequest; @@ -89,7 +88,7 @@ public void testVirtualHostNormalization() throws Exception IsHandledHandler handlerC = new IsHandledHandler(); contextC.setHandler(handlerC); - HandlerCollection c = new HandlerCollection(); + HandlerList c = new HandlerList(); c.addHandler(contextA); c.addHandler(contextB); @@ -178,7 +177,7 @@ public void testNamedConnector() throws Exception contextH.setHandler(handlerH); contextH.setVirtualHosts(new String[]{"*.com"}); - HandlerCollection c = new HandlerCollection(); + HandlerList c = new HandlerList(); c.addHandler(contextA); c.addHandler(contextB); c.addHandler(contextC); @@ -271,7 +270,7 @@ public void testNamedConnector() throws Exception } // Reversed order to check priority when multiple matches - HandlerCollection d = new HandlerCollection(); + HandlerList d = new HandlerList(); d.addHandler(contextH); d.addHandler(contextG); d.addHandler(contextF); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java index bd88dee2952c..1def256c28b0 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java @@ -25,7 +25,6 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.tools.HttpTester; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.junit.jupiter.api.AfterEach; @@ -52,9 +51,7 @@ public void before() throws Exception ContextHandlerCollection contexts = new ContextHandlerCollection(); handler = new DefaultHandler(); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[]{contexts, handler}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, handler)); handler.setServeIcon(true); handler.setShowContexts(true); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/HandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/HandlerTest.java index c3738b096632..99eb1264ef66 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/HandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/HandlerTest.java @@ -36,7 +36,6 @@ public class HandlerTest { - @Test public void testWrapperSetServer() { @@ -117,16 +116,16 @@ public void testWrapperChainLoop() } @Test - public void testCollectionSetServer() + public void testHandlerListSetServer() { Server s = new Server(); - HandlerCollection a = new HandlerCollection(); - HandlerCollection b = new HandlerCollection(); - HandlerCollection b1 = new HandlerCollection(); - HandlerCollection b2 = new HandlerCollection(); - HandlerCollection c = new HandlerCollection(); - HandlerCollection c1 = new HandlerCollection(); - HandlerCollection c2 = new HandlerCollection(); + HandlerList a = new HandlerList(); + HandlerList b = new HandlerList(); + HandlerList b1 = new HandlerList(); + HandlerList b2 = new HandlerList(); + HandlerList c = new HandlerList(); + HandlerList c1 = new HandlerList(); + HandlerList c2 = new HandlerList(); a.addHandler(b); a.addHandler(c); @@ -143,16 +142,16 @@ public void testCollectionSetServer() } @Test - public void testCollectionServerSet() + public void testHandlerListServerSet() { Server s = new Server(); - HandlerCollection a = new HandlerCollection(); - HandlerCollection b = new HandlerCollection(); - HandlerCollection b1 = new HandlerCollection(); - HandlerCollection b2 = new HandlerCollection(); - HandlerCollection c = new HandlerCollection(); - HandlerCollection c1 = new HandlerCollection(); - HandlerCollection c2 = new HandlerCollection(); + HandlerList a = new HandlerList(); + HandlerList b = new HandlerList(); + HandlerList b1 = new HandlerList(); + HandlerList b2 = new HandlerList(); + HandlerList c = new HandlerList(); + HandlerList c1 = new HandlerList(); + HandlerList c2 = new HandlerList(); a.setServer(s); a.addHandler(b); @@ -169,24 +168,24 @@ public void testCollectionServerSet() } @Test - public void testCollectionThisLoop() + public void testHandlerListThisLoop() { - HandlerCollection a = new HandlerCollection(); + HandlerList a = new HandlerList(); IllegalStateException e = assertThrows(IllegalStateException.class, () -> a.addHandler(a)); assertThat(e.getMessage(), containsString("loop")); } @Test - public void testCollectionDeepLoop() + public void testHandlerListDeepLoop() { - HandlerCollection a = new HandlerCollection(); - HandlerCollection b = new HandlerCollection(); - HandlerCollection b1 = new HandlerCollection(); - HandlerCollection b2 = new HandlerCollection(); - HandlerCollection c = new HandlerCollection(); - HandlerCollection c1 = new HandlerCollection(); - HandlerCollection c2 = new HandlerCollection(); + HandlerList a = new HandlerList(); + HandlerList b = new HandlerList(); + HandlerList b1 = new HandlerList(); + HandlerList b2 = new HandlerList(); + HandlerList c = new HandlerList(); + HandlerList c1 = new HandlerList(); + HandlerList c2 = new HandlerList(); a.addHandler(b); a.addHandler(c); @@ -198,15 +197,15 @@ public void testCollectionDeepLoop() } @Test - public void testCollectionChainLoop() + public void testHandlerListChainLoop() { - HandlerCollection a = new HandlerCollection(); - HandlerCollection b = new HandlerCollection(); - HandlerCollection b1 = new HandlerCollection(); - HandlerCollection b2 = new HandlerCollection(); - HandlerCollection c = new HandlerCollection(); - HandlerCollection c1 = new HandlerCollection(); - HandlerCollection c2 = new HandlerCollection(); + HandlerList a = new HandlerList(); + HandlerList b = new HandlerList(); + HandlerList b1 = new HandlerList(); + HandlerList b2 = new HandlerList(); + HandlerList c = new HandlerList(); + HandlerList c1 = new HandlerList(); + HandlerList c2 = new HandlerList(); a.addHandler(c); b.setHandlers(new Handler[]{b1, b2}); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java index 4ee0fb69ddfe..1053b71ec473 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java @@ -432,8 +432,7 @@ public void testLogHandlerCollectionFirst(String logType, Handler testHandler, S setup(logType); RequestLogHandler handler = new RequestLogHandler(); handler.setRequestLog(_log); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[]{handler, testHandler}); + HandlerList handlers = new HandlerList(handler, testHandler); _server.setHandler(handlers); startServer(); makeRequest(requestPath); @@ -454,8 +453,7 @@ public void testLogHandlerCollectionLast(String logType, Handler testHandler, St testHandler instanceof ResponseSendErrorHandler ); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[]{testHandler, handler}); + HandlerCollection handlers = new HandlerCollection(testHandler, handler); _server.setHandler(handlers); startServer(); makeRequest(requestPath); diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java index 37726292fcda..4e3dbadc0bd4 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java @@ -126,11 +126,7 @@ public static void startServer() throws Exception contextHandlers.setHandlers(new Handler[]{redirectHandler, rootContext, test1Context, test2Context}); // Create server level handler tree - HandlerList handlers = new HandlerList(); - handlers.addHandler(contextHandlers); - handlers.addHandler(new DefaultHandler()); // round things out - - server.setHandler(handlers); + server.setHandler(new HandlerList(contextHandlers, new DefaultHandler())); server.start(); diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java index b174c80a9e53..ae01a30d6491 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextDispatchWithQueryStrings.java @@ -26,7 +26,6 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.DefaultHandler; @@ -60,10 +59,7 @@ public void setUp() throws Exception _contextHandler.addServlet(new ServletHolder(new TestServlet()), "/firstDispatchWithNewQueryString"); _contextHandler.addServlet(new ServletHolder(new TestServlet()), "/secondDispatchNewValueForExistingQueryString"); - HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[]{_contextHandler, new DefaultHandler()}); - - _server.setHandler(handlers); + _server.setHandler(new HandlerList(_contextHandler, new DefaultHandler())); _server.start(); } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java index 23b3ad97101c..48cf13801511 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/AsyncContextTest.java @@ -34,7 +34,6 @@ import org.eclipse.jetty.http.tools.HttpTester; import org.eclipse.jetty.logging.StacklessLogging; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.LocalConnector; @@ -99,11 +98,7 @@ public void setUp() throws Exception errorHandler.addErrorPage(500, "/error/500"); errorHandler.addErrorPage(IOException.class.getName(), "/error/IOE"); - HandlerList handlers = new HandlerList(); - handlers.setHandlers(new Handler[] - {_contextHandler, new DefaultHandler()}); - - _server.setHandler(handlers); + _server.setHandler(new HandlerList(_contextHandler, new DefaultHandler())); _server.start(); } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultHandlerTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultHandlerTest.java index d3d6bbf816d8..d7cd7aebf7f5 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultHandlerTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultHandlerTest.java @@ -70,12 +70,7 @@ public void startServer() throws Exception contextFoo.setContextPath("/foo"); contextFoo.setBaseResource(new PathResource(baseFoo)); - HandlerList handlers = new HandlerList(); - handlers.addHandler(contextA); - handlers.addHandler(contextFoo); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(contextA, contextFoo, new DefaultHandler())); server.start(); } diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java index a462e89b6a3f..6c916b53ed86 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletRequestLogTest.java @@ -389,16 +389,9 @@ public void testLogHandlerCollectionErrorHandlerServerBean(Servlet testServlet, ErrorHandler errorHandler = new ErrorHandler(); server.addBean(errorHandler); - // First the behavior as defined in etc/jetty.xml - // id="Handlers" - HandlerList handlers = new HandlerList(); - // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); - // id="DefaultHandler" DefaultHandler defaultHandler = new DefaultHandler(); - - handlers.setHandlers(new Handler[]{contexts, defaultHandler}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, defaultHandler)); // Next the behavior as defined by etc/jetty-requestlog.xml // the id="RequestLog" @@ -477,16 +470,8 @@ public void testLogHandlerCollectionSimpleErrorPageMapping(Servlet testServlet, connector.setPort(0); server.setConnectors(new Connector[]{connector}); - // First the behavior as defined in etc/jetty.xml - // id="Handlers" - HandlerList handlers = new HandlerList(); - // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); - // id="DefaultHandler" - DefaultHandler defaultHandler = new DefaultHandler(); - - handlers.setHandlers(new Handler[]{contexts, defaultHandler}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, new DefaultHandler())); // Next the behavior as defined by etc/jetty-requestlog.xml // the id="RequestLog" @@ -571,15 +556,11 @@ public void testLogHandlerWrapped(Servlet testServlet, String requestPath, Strin server.setConnectors(new Connector[]{connector}); // First the behavior as defined in etc/jetty.xml (as is) - // id="Handlers" - HandlerList handlers = new HandlerList(); // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); // id="DefaultHandler" DefaultHandler defaultHandler = new DefaultHandler(); - - handlers.setHandlers(new Handler[]{contexts, defaultHandler}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, defaultHandler)); // Next the proposed behavioral change to etc/jetty-requestlog.xml // the id="RequestLog" diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletWrapperTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletWrapperTest.java index d9ca26b31d68..3352096bbc80 100644 --- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletWrapperTest.java +++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/ServletWrapperTest.java @@ -71,11 +71,7 @@ public void startServer() throws Exception FilterHolder filterHolder = context.addFilter(WrapFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); filterHolder.setAsyncSupported(true); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java index 8bd2d5c19168..7bb613c79c5a 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java @@ -188,11 +188,7 @@ public void startServer() throws Exception ServletHolder holder = context.addServlet(MultipartServlet.class, "/multipart"); holder.getRegistration().setMultipartConfig(multipartConfig); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java index f9704788735a..d3a3314fd6e6 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java @@ -81,10 +81,7 @@ protected void doStart() throws Exception server.addConnector(connector); // Add Handler - HandlerList handlers = new HandlerList(); - handlers.addHandler(new WebSocketUpgradeHandler(negotiator)); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(new WebSocketUpgradeHandler(negotiator), new DefaultHandler())); // Start Server addBean(server); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/RestartContextTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/RestartContextTest.java index dc8457956642..4fcbf33318c1 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/RestartContextTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/RestartContextTest.java @@ -72,12 +72,7 @@ public void testStartStopStartServletContextListener() throws Exception context.addEventListener(new AddEndpointListener()); // Setup handler tree - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - // Add handler tree to server - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); // Start server server.start(); @@ -114,9 +109,7 @@ public void testStartStopStartConfigurator() throws Exception }); // Setup handler tree - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); + HandlerList handlers = new HandlerList(context, new DefaultHandler()); // Add handler tree to server server.setHandler(handlers); diff --git a/jetty-websocket/websocket-jetty-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserDebugTool.java b/jetty-websocket/websocket-jetty-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserDebugTool.java index 88ea12759822..2ddb8dfb14c6 100644 --- a/jetty-websocket/websocket-jetty-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserDebugTool.java +++ b/jetty-websocket/websocket-jetty-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserDebugTool.java @@ -114,11 +114,7 @@ public void prepare(int port) ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); context.addServlet(defHolder, "/"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); LOG.info("{} setup on port {}", this.getClass().getName(), port); } diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/BadNetworkTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/BadNetworkTest.java index 4efcc4ab8ca9..d3d5b08783a4 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/BadNetworkTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/BadNetworkTest.java @@ -86,10 +86,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(holder, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientCloseTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientCloseTest.java index 5d3534fc585d..2561ef271627 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientCloseTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientCloseTest.java @@ -136,10 +136,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(holder, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientSessionsTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientSessionsTest.java index d612814d06d0..4ce370a41a82 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientSessionsTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/ClientSessionsTest.java @@ -79,10 +79,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(holder, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/SlowClientTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/SlowClientTest.java index 978d1fda7956..97c21eb99934 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/SlowClientTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/client/SlowClientTest.java @@ -81,11 +81,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(websocket, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameAnnotationTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameAnnotationTest.java index c79c67582f5e..bbb3f8060eab 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameAnnotationTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameAnnotationTest.java @@ -90,11 +90,7 @@ protected void configure(JettyWebSocketServletFactory factory) context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameListenerTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameListenerTest.java index dc2107f2727e..7306732bf22d 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameListenerTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/FrameListenerTest.java @@ -83,11 +83,7 @@ public void configure(JettyWebSocketServletFactory factory) context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java index 1c2804d59f49..01ee6ed03460 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java @@ -86,11 +86,7 @@ public void configure(JettyWebSocketServletFactory factory) context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerCloseTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerCloseTest.java index 3277da8b00cc..2229e931bd4d 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerCloseTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/ServerCloseTest.java @@ -85,11 +85,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(closeEndpoint, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/SlowServerTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/SlowServerTest.java index f48f3846bc7b..c27e82518074 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/SlowServerTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/SlowServerTest.java @@ -81,11 +81,7 @@ public void configure(JettyWebSocketServletFactory factory) }); context.addServlet(websocket, "/ws"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DeploymentErrorTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DeploymentErrorTest.java index 8d823d125c90..f4776e79653c 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DeploymentErrorTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DeploymentErrorTest.java @@ -41,13 +41,12 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.io.RuntimeIOException; import org.eclipse.jetty.logging.StacklessLogging; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -113,10 +112,7 @@ public Path startServer(Consumer docrootSetupConsumer) throws Exception server.addBean(deploymentManager); // Server handlers - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[] - {contexts, new DefaultHandler()}); - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, new DefaultHandler())); // Setup Configurations Configurations.setServerDefault(server) diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java index 059303e8c243..57004f832342 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/DigestPostTest.java @@ -45,12 +45,11 @@ import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.authentication.DigestAuthenticator; import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.TypeUtil; @@ -141,10 +140,7 @@ public static void setUpServer() security.setConstraintMappings(Collections.singletonList(mapping)); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[] - {context, new DefaultHandler()}); - _server.setHandler(handlers); + _server.setHandler(new HandlerList(context, new DefaultHandler())); _server.start(); } diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/FailedSelectorTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/FailedSelectorTest.java index f31db9e212fc..a1aa817edd31 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/FailedSelectorTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/FailedSelectorTest.java @@ -116,11 +116,7 @@ public void startServer(Function customizeServerConsume ServletHolder closeHolder = new ServletHolder(new CloseSelectorServlet(connector)); context.addServlet(closeHolder, "/selector/close"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(context); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(context, new DefaultHandler())); server.start(); } diff --git a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java index 994a8607144b..3ac0a52602d8 100644 --- a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java +++ b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java @@ -41,10 +41,9 @@ import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.security.LoginService; import org.eclipse.jetty.security.authentication.BasicAuthenticator; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; @@ -236,8 +235,6 @@ protected void configureServer() throws Exception _handler = new TestHandler(_resourceBase); - HandlerCollection handlers = new HandlerCollection(); - handlers.setHandlers(new Handler[]{_handler, root}); - security.setHandler(handlers); + security.setHandler(new HandlerList(_handler, root)); } } diff --git a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RequestDispatchedSessionTest.java b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RequestDispatchedSessionTest.java index 935577a4f14d..7a7b6cae5ee3 100644 --- a/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RequestDispatchedSessionTest.java +++ b/tests/test-sessions/test-sessions-common/src/test/java/org/eclipse/jetty/server/session/RequestDispatchedSessionTest.java @@ -65,11 +65,7 @@ public void startServer() throws Exception contextHandler.addServlet(ShowUserServlet.class, "/user"); contextHandler.addServlet(DefaultServlet.class, "/"); - HandlerList handlers = new HandlerList(); - handlers.addHandler(contextHandler); - handlers.addHandler(new DefaultHandler()); - - server.setHandler(handlers); + server.setHandler(new HandlerList(contextHandler, new DefaultHandler())); server.start(); } diff --git a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java index 31b249b63406..cba5f2233b54 100644 --- a/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java +++ b/tests/test-webapps/test-jetty-webapp/src/test/java/org/eclipse/jetty/TestServer.java @@ -32,7 +32,6 @@ import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.server.CustomRequestLog; import org.eclipse.jetty.server.ForwardedRequestCustomizer; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Request; @@ -42,7 +41,7 @@ import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerWrapper; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.session.DefaultSessionCache; @@ -98,10 +97,8 @@ public static void main(String[] args) throws Exception server.addConnector(httpConnector); // Handlers - HandlerCollection handlers = new HandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(); - handlers.setHandlers(new Handler[] - {contexts, new DefaultHandler()}); + HandlerList handlers = new HandlerList(contexts, new DefaultHandler()); // Add restart handler to test the ability to save sessions and restart RestartHandler restart = new RestartHandler(); diff --git a/tests/test-webapps/test-proxy-webapp/src/test/java/org/eclipse/jetty/TestTransparentProxyServer.java b/tests/test-webapps/test-proxy-webapp/src/test/java/org/eclipse/jetty/TestTransparentProxyServer.java index 1bd261c11112..96a88bb834b2 100644 --- a/tests/test-webapps/test-proxy-webapp/src/test/java/org/eclipse/jetty/TestTransparentProxyServer.java +++ b/tests/test-webapps/test-proxy-webapp/src/test/java/org/eclipse/jetty/TestTransparentProxyServer.java @@ -25,7 +25,6 @@ import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.server.ForwardedRequestCustomizer; -import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.SecureRequestCustomizer; @@ -34,7 +33,7 @@ import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.webapp.WebAppContext; @@ -107,12 +106,8 @@ public static void main(String[] args) throws Exception server.addConnector(http2Connector); // Handlers - HandlerCollection handlers = new HandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(); - handlers.setHandlers(new Handler[] - {contexts, new DefaultHandler()}); - - server.setHandler(handlers); + server.setHandler(new HandlerList(contexts, new DefaultHandler())); // Setup proxy webapp WebAppContext webapp = new WebAppContext();