From 2addb6a655ac40ac120be0e5cb33c59a91052024 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 15 Apr 2020 18:42:28 +0200 Subject: [PATCH] Jetty 10.0.x use HandlerList instead of HandlerCollection (#4757) * Use HandlerList instead of HandlerCollection Signed-off-by: Greg Wilkins * 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 | 7 +- .../eclipse/jetty/embedded/ManyHandlers.java | 2 +- .../jetty/embedded/WebSocketJsrServer.java | 6 +- .../src/main/resources/exampleserver.xml | 2 +- .../src/main/resources/jetty-otherserver.xml | 2 +- .../eclipse/jetty/ant/ServerProxyImpl.java | 16 +- .../jetty/deploy/BadAppDeployTest.java | 21 +- jetty-deploy/src/test/resources/jetty.xml | 2 +- .../http/spi/JettyHttpServerProvider.java | 6 +- .../jetty/http/spi/util/SpiUtility.java | 110 ---- .../jetty/maven/plugin/ServerSupport.java | 17 +- .../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 +- .../handler/CookiePatternRuleTest.java | 6 +- .../jetty-rewrite.xml | 499 +++++++++--------- .../java/org/eclipse/jetty/runner/Runner.java | 3 +- .../jetty/security/AliasedConstraintTest.java | 5 +- jetty-server/src/main/config/etc/jetty.xml | 12 +- .../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 | 29 +- .../jetty/servlet/ServletWrapperTest.java | 6 +- .../src/main/config/etc/jetty-spring.xml | 2 +- .../org/eclipse/jetty/spring/jetty.xml | 2 +- .../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 +- .../src/test/resources/DefaultHandler.xml | 4 +- .../src/test/resources/RFC2616Base.xml | 6 +- .../src/test/resources/basic-server.xml | 2 +- .../jetty/DatabaseLoginServiceTestServer.java | 7 +- .../session/RequestDispatchedSessionTest.java | 6 +- .../java/org/eclipse/jetty/TestServer.java | 7 +- .../jetty/TestTransparentProxyServer.java | 9 +- 65 files changed, 444 insertions(+), 753 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 1eed27836c6..538c06486fb 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 class ExampleServer 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 2254cce0a69..745a551acd5 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.HttpServletRequest; 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 class FastFileServer { 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 58d32b93446..fbff826fdd8 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 @@ package org.eclipse.jetty.embedded; 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 class FileServer 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 ca285e010dd..b5b41164869 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 class JarServer 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 ea16f69c68b..b094964df53 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.security.HashLoginService; 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; @@ -51,7 +50,7 @@ import org.eclipse.jetty.server.ServerConnector; 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,10 +104,8 @@ public class LikeJettyXml // httpConfig.addCustomizer(new ForwardedRequestCustomizer()); // Handler Structure - 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())); // === 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 77dd973eafe..58df808147d 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 class ManyHandlers 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 86c88c703e3..26fa623cdbe 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 class WebSocketJsrServer { 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 class WebSocketJsrServer } ); - 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 138bdfd53b0..b3940b8f20a 100644 --- a/examples/embedded/src/main/resources/exampleserver.xml +++ b/examples/embedded/src/main/resources/exampleserver.xml @@ -25,7 +25,7 @@ - + diff --git a/examples/embedded/src/main/resources/jetty-otherserver.xml b/examples/embedded/src/main/resources/jetty-otherserver.xml index 89596307069..2a4c4d361c4 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-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java b/jetty-ant/src/main/java/org/eclipse/jetty/ant/ServerProxyImpl.java index 16460fe7c18..e71da97c657 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.types.ContextHandlers; 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.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.util.Scanner; import org.eclipse.jetty.util.resource.PathResource; import org.eclipse.jetty.util.resource.Resource; @@ -406,23 +406,15 @@ public class ServerProxyImpl implements ServerProxy 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 0c99e06d673..6a6ee4fb9d8 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.Server; 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 class BadAppDeployTest 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 class BadAppDeployTest 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 class BadAppDeployTest ### 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 class BadAppDeployTest 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-deploy/src/test/resources/jetty.xml b/jetty-deploy/src/test/resources/jetty.xml index 7901921d362..f3ada0bf854 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-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 43ab5f8242e..a9a875c8402 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 java.net.InetSocketAddress; 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 class JettyHttpServerProvider extends HttpServerProvider 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 264a880cc25..00000000000 --- 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 b1001c744b4..95024bb85ea 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 java.util.Map; 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 class ServerSupport 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-maven-plugin/src/test/resources/embedder-jetty.xml b/jetty-maven-plugin/src/test/resources/embedder-jetty.xml index 85ae556bdda..a7ad2021f67 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 d4bac27248f..b73820e42e4 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 6c2b9d68082..4561574d208 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 25f831c57c5..1d10384859c 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 1dc494ce93f..e123113c5c2 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 90e983f7b14..41be9bb7180 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 81db59e9457..a3e0f8bf7ac 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 @@ import org.eclipse.jetty.server.handler.HandlerWrapper; * </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/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java b/jetty-rewrite/src/test/java/org/eclipse/jetty/rewrite/handler/CookiePatternRuleTest.java index 08253d96c50..9fd364b8627 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 class CookiePatternRuleTest } }; - 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-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 dedac35bc32..2688e21964c 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 - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + 30000 - + + - - - - - - - - - - - - - - - - /contexts - 1 - - - + + + + + - - - - - - - - - - - - - - - - - - /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 + 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 + + + + + + + + + + + + + + + + + + + + + + - + + - - - - true - 1000 + + + + + + + + + + + + + + + + + + /contexts + + 1 + + + + + + + + + + + + + + + + + + + + + + + + /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 + + + + + + + + true + 1000 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 0e67904d8f4..9b3ab625ca2 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.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.StatisticsHandler; import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.servlet.ServletContextHandler; @@ -341,7 +342,7 @@ public class Runner 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 413bebee3ec..92d93d366d1 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 java.util.stream.Stream; 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 class AliasedConstraintTest 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/config/etc/jetty.xml b/jetty-server/src/main/config/etc/jetty.xml index 0c6f3b4d948..cf4e989eee5 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/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java b/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java index a45a8d91be2..52dd7d94c6b 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.http.HttpParser; 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 class PartialRFC2616Test 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 11ce1879cc7..3fe424c2072 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 class ServerConnectorTest 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 class ServerConnectorTest 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 class ServerConnectorTest 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 class ServerConnectorTest connector.setPort(port); server.addConnector(connector); - HandlerList handlers = new HandlerList(); - handlers.addHandler(new DefaultHandler()); + server.setHandler(new HandlerList(new DefaultHandler())); - server.setHandler(handlers); - - 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 f9c05bed48a..dd4ee094d0d 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 class ContextHandlerCollectionTest 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 dbbc0d6e274..598ceb86801 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.nio.file.Path; 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 class ContextHandlerTest 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 class ContextHandlerTest 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 class ContextHandlerTest } // 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 bd88dee2952..1def256c28b 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 java.nio.charset.StandardCharsets; 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 class DefaultHandlerTest 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 c3738b09663..99eb1264ef6 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 @@ import static org.junit.jupiter.api.Assertions.assertThrows; public class HandlerTest { - @Test public void testWrapperSetServer() { @@ -117,16 +116,16 @@ public class HandlerTest } @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 class HandlerTest } @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 class HandlerTest } @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 class HandlerTest } @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 4ee0fb69ddf..1053b71ec47 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 class NcsaRequestLogTest 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 class NcsaRequestLogTest 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 37726292fcd..4e3dbadc0bd 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 class SecuredRedirectHandlerTest 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 b174c80a9e5..ae01a30d649 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.HttpServletRequest; 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 class AsyncContextDispatchWithQueryStrings _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 23b3ad97101..48cf1380151 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 javax.servlet.http.HttpServletResponseWrapper; 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 class AsyncContextTest 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 d3d6bbf816d..d7cd7aebf7f 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 class DefaultHandlerTest 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 0965236b8a4..6c916b53ed8 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.ServerConnector; 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 class ServletRequestLogTest // 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" @@ -389,16 +389,9 @@ public class ServletRequestLogTest ErrorHandler errorHandler = new ErrorHandler(); server.addBean(errorHandler); - // First the behavior as defined in etc/jetty.xml - // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); - // 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 class ServletRequestLogTest connector.setPort(0); server.setConnectors(new Connector[]{connector}); - // First the behavior as defined in etc/jetty.xml - // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); - // 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 class ServletRequestLogTest server.setConnectors(new Connector[]{connector}); // First the behavior as defined in etc/jetty.xml (as is) - // id="Handlers" - HandlerCollection handlers = new HandlerCollection(); // 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 d9ca26b31d6..3352096bbc8 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 class ServletWrapperTest 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-spring/src/main/config/etc/jetty-spring.xml b/jetty-spring/src/main/config/etc/jetty-spring.xml index 637450d51a7..40a5e7cf1bb 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 28915187ad8..57b87cc407b 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/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/HugeResourceTest.java index 8bd2d5c1916..7bb613c79c5 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 class HugeResourceTest 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 f9704788735..d3a3314fd6e 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 @@ public class CoreServer extends ContainerLifeCycle 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 dc845795664..4fcbf33318c 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 class RestartContextTest 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 class RestartContextTest }); // 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 88ea1275982..2ddb8dfb14c 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 class BrowserDebugTool 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 4efcc4ab8ca..d3d5b08783a 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 class BadNetworkTest }); 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 5d3534fc585..2561ef27162 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 class ClientCloseTest }); 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 d612814d06d..4ce370a41a8 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 class ClientSessionsTest }); 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 978d1fda795..97c21eb9993 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 class SlowClientTest }); 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 c79c67582f5..bbb3f8060ea 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 @@ public class FrameAnnotationTest 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 dc2107f2727..7306732bf22 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 class FrameListenerTest 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 1c2804d59f4..01ee6ed0346 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 class PartialListenerTest 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 3277da8b00c..2229e931bd4 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 class ServerCloseTest }); 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 f48f3846bc7..c27e8251807 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 class SlowServerTest }); 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 8d823d125c9..f4776e79653 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.HttpMethod; 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 class DeploymentErrorTest 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 059303e8c24..57004f83234 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.ConstraintMapping; 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 class DigestPostTest 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 f31db9e212f..a1aa817edd3 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 class FailedSelectorTest 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-integration/src/test/resources/DefaultHandler.xml b/tests/test-integration/src/test/resources/DefaultHandler.xml index 992bea97225..e23d89e6d0e 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 ed55b90a72d..aad3e838d43 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 fefca7e39e8..74283e41641 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 @@ - + 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 994a8607144..3ac0a52602d 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.ConstraintMapping; 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 @@ public class DatabaseLoginServiceTestServer _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 935577a4f14..7a7b6cae5ee 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 class RequestDispatchedSessionTest 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 31b249b6340..cba5f2233b5 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.jmx.MBeanContainer; 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.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.server.handler.HandlerWrapper; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.session.DefaultSessionCache; @@ -98,10 +97,8 @@ public class TestServer 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 1bd261c1111..96a88bb834b 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.HTTP2Cipher; 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.ServerConnector; 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 class TestTransparentProxyServer 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();