From 39e5667f1d7a7c23df3f58e265f3454dfcf5eb41 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 25 Jan 2023 08:08:09 +1100 Subject: [PATCH] Jetty-12 Remove usage of HandlerList and reduce usage of Handler.Collection (#9191) * Remove usage of HandlerList and reduce usage of Handler.Collection "The best part is no part" - Elon Musk! The overwhelming usage of `HandlerList` and `Handler.Collection` was for adding the `DefaultHandler` after the main handler. This PR adds a getter/setter for a `DefaultHandler` on the server, so we no longer need to always create a `Handler.Collection` structure. This has allowed the deprecated `HandlerList` and `HandlerWrapper` classes to be removed. In implementing this PR, several problems were found in the calculation of `InvocationType`, not least that it was assumed that an empty `Handler.Collection` was `BLOCKING`. When this issue was fixed, any dynamic addition of contexts (deployer or SPI server) failed as the `InvocationType` changed. So this PR also introduces the `isDynamic()` attribute of all `Handler.Container`s. A dynamic container will always return `BLOCKING` from `getInvocationType()`, as there is always a race with a new handler being added. A non-dynamic container will return a real `InvocationType`, calculated from its children, but it's mutator methods will ISE if contained handlers are changed. Signed-off-by: Simone Bordet Co-authored-by: Jan Bartel Co-authored-by: Simone Bordet --- .../http/server-http-handler-implement.adoc | 2 +- .../server/http/server-http-handler-use.adoc | 27 +- .../server/http/server-http-handler.adoc | 22 +- .../server/http/HTTPServerDocs.java | 57 ++-- .../jetty-deploy/src/test/resources/jetty.xml | 20 +- .../jetty/http/spi/JettyHttpServer.java | 8 +- .../http/spi/JettyHttpServerProvider.java | 6 +- .../jetty-rewrite.xml | 13 +- .../src/main/config/etc/jetty.xml | 25 +- .../src/main/config/modules/server.mod | 10 + .../org/eclipse/jetty/server/Handler.java | 103 ++++++- .../java/org/eclipse/jetty/server/Server.java | 50 +++- .../handler/ContextHandlerCollection.java | 13 + .../jetty/server/handler/DefaultHandler.java | 25 +- .../jetty/server/handler/HandlerList.java | 33 --- .../jetty/server/handler/HandlerWrapper.java | 26 -- .../jetty/server/handler/HotSwapHandler.java | 1 + .../server/handler/PathMappingsHandler.java | 10 + .../jetty/server/handler/ShutdownHandler.java | 9 +- .../jetty/server/PartialRFC2616Test.java | 20 +- .../handler/ContextHandlerCollectionTest.java | 2 +- .../server/handler/DefaultHandlerTest.java | 6 +- .../server/handler/NcsaRequestLogTest.java | 2 +- .../server/handler/ResourceHandlerTest.java | 2 +- .../SecuredRedirectHandlerCodeTest.java | 2 +- .../handler/SecuredRedirectHandlerTest.java | 2 +- .../server/handler/ShutdownHandlerTest.java | 4 +- .../src/main/resources/exampleserver.xml | 32 +-- .../src/main/resources/fileserver.xml | 30 +- .../src/test/resources/embedder-jetty.xml | 27 +- .../config/etc/jetty-with-custom-class.xml | 13 +- .../src/test/config/etc/jetty.xml | 13 +- .../ee10/servlet/DefaultServletTest.java | 2 +- .../security/AliasedConstraintTest.java | 4 +- .../src/test/resources/DefaultHandler.xml | 31 +- .../src/test/resources/RFC2616Base.xml | 69 +++-- .../test/resources/add-jetty-test-webapp.xml | 2 +- .../src/test/resources/basic-server.xml | 13 +- .../websocket/jakarta/tests/CoreServer.java | 4 +- .../jakarta/tests/RestartContextTest.java | 9 +- .../server/browser/BrowserDebugTool.java | 4 +- .../tests/client/BadNetworkTest.java | 4 +- .../tests/client/ClientCloseTest.java | 4 +- .../tests/client/ClientSessionsTest.java | 4 +- .../tests/client/SlowClientTest.java | 4 +- .../tests/server/FrameAnnotationTest.java | 4 +- .../tests/server/FrameListenerTest.java | 4 +- .../tests/server/PartialListenerTest.java | 4 +- .../tests/server/ServerCloseTest.java | 4 +- .../tests/server/SlowServerTest.java | 4 +- .../jetty/ee9/ant/ServerProxyImpl.java | 3 +- .../jetty/ee9/demos/FastFileServer.java | 6 +- .../eclipse/jetty/ee9/demos/JarServer.java | 2 - .../eclipse/jetty/ee9/demos/LikeJettyXml.java | 2 +- .../src/main/resources/exampleserver.xml | 26 +- .../src/main/resources/fileserver.xml | 34 +-- .../src/test/resources/embedder-jetty.xml | 14 +- .../jetty/ee9/nested/ShutdownHandler.java | 265 ------------------ .../jettyhome/etc/jetty.xml | 13 +- .../config/etc/jetty-with-custom-class.xml | 13 +- .../src/test/config/etc/jetty.xml | 13 +- .../org/eclipse/jetty/ee9/runner/Runner.java | 1 - .../ee9/servlet/ServletRequestLogTest.java | 49 ++-- .../jetty/ee9/test/DeploymentErrorTest.java | 3 +- .../jetty/ee9/test/DigestPostTest.java | 3 +- .../jetty/ee9/test/FailedSelectorTest.java | 3 +- .../src/test/resources/DefaultHandler.xml | 31 +- .../src/test/resources/RFC2616Base.xml | 114 ++++---- .../src/test/resources/basic-server.xml | 13 +- .../DatabaseLoginServiceTestServer.java | 1 - .../websocket/jakarta/tests/CoreServer.java | 4 +- .../jakarta/tests/RestartContextTest.java | 11 +- .../server/browser/BrowserDebugTool.java | 4 +- .../tests/client/BadNetworkTest.java | 4 +- .../tests/client/ClientCloseTest.java | 4 +- .../tests/client/ClientSessionsTest.java | 4 +- .../tests/client/SlowClientTest.java | 4 +- .../tests/server/FrameAnnotationTest.java | 4 +- .../tests/server/FrameListenerTest.java | 4 +- .../tests/server/PartialListenerTest.java | 4 +- .../tests/server/ServerCloseTest.java | 4 +- .../tests/server/SlowServerTest.java | 4 +- 82 files changed, 494 insertions(+), 959 deletions(-) delete mode 100644 jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerList.java delete mode 100644 jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java delete mode 100644 jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ShutdownHandler.java diff --git a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-implement.adoc b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-implement.adoc index 87ba29fc22f..51f260e8bf3 100644 --- a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-implement.adoc +++ b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-implement.adoc @@ -50,5 +50,5 @@ A filtering `Handler` is a handler that perform some modification to the request include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=handlerFilter] ---- -Note how a filtering `Handler` extends from `HandlerWrapper` and as such needs another handler to forward the request processing to, and how the two ``Handler``s needs to be linked together to work properly. +Note how a filtering `Handler` extends from `Handler.Wrapper` and as such needs another handler to forward the request processing to, and how the two ``Handler``s needs to be linked together to work properly. diff --git a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-use.adoc b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-use.adoc index a3df908ba12..35972f1ec0f 100644 --- a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-use.adoc +++ b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler-use.adoc @@ -70,14 +70,14 @@ Server Server applications may need to deploy to Jetty more than one web application. -Recall from the xref:pg-server-http-handler[introduction] that Jetty offers `HandlerCollection` and `HandlerList` that may contain a sequence of children ``Handler``s. -However, both of these have no knowledge of the concept of _context_ and just iterate through the sequence of ``Handler``s. +Recall from the xref:pg-server-http-handler[introduction] that Jetty offers `Handler.Collection` that contains a sequence of child ``Handler``s. +However, this has no knowledge of the concept of _context_ and just iterates through the sequence of ``Handler``s. A better choice for multiple web application is `ContextHandlerCollection`, that matches a _context_ from either its _context path_ or _virtual host_, without iterating through the ``Handler``s. -If `ContextHandlerCollection` does not find a match, it just returns. +If `ContextHandlerCollection` does not find a match, it just returns `false` from its `process(\...)` method. What happens next depends on the `Handler` tree structure: other ``Handler``s may be invoked after `ContextHandlerCollection`, for example `DefaultHandler` (see xref:pg-server-http-handler-use-util-default-handler[this section]). -Eventually, if `Request.setHandled(true)` is not called, Jetty returns an HTTP `404` response to the client. +Eventually, if no `Handler` returns `true` from their own `process(\...)` method, then Jetty returns an HTTP `404` response to the client. [source,java,indent=0] ---- @@ -132,7 +132,7 @@ If you need to serve static resources from multiple directories: include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java[tags=multipleResourcesHandler] ---- -If the resource is not found, `ResourceHandler` will not call `Request.setHandled(true)` so what happens next depends on the `Handler` tree structure. +If the resource is not found, `ResourceHandler` will not return `true` from the `process(\...)` method, so what happens next depends on the `Handler` tree structure. See also xref:pg-server-http-handler-use-util-default-handler[how to use] `DefaultHandler`. [[pg-server-http-handler-use-util-gzip-handler]] @@ -277,7 +277,7 @@ include::../../{doc_code}/org/eclipse/jetty/docs/programming/server/http/HTTPSer [[pg-server-http-handler-use-util-default-handler]] ====== DefaultHandler -`DefaultHandler` is a terminal `Handler` that always calls `Request.setHandled(true)` and performs the following: +`DefaultHandler` is a terminal `Handler` that always returns `true` from its `process(\...)` method and performs the following: * Serves the `favicon.ico` Jetty icon when it is requested * Sends a HTTP `404` response for any other request @@ -295,12 +295,11 @@ The `Handler` tree structure looks like the following: [source,screen] ---- Server -└── HandlerList - ├── ContextHandlerCollection - │ ├── ContextHandler 1 - │ :── ... - │ └── ContextHandler N - └── DefaultHandler + ├── ContextHandlerCollection + │ ├── ContextHandler 1 + │ :── ... + │ └── ContextHandler N + └── DefaultHandler ---- In the example above, `ContextHandlerCollection` will try to match a request to one of the contexts; if the match fails, `HandlerList` will call the next `Handler` which is `DefaultHandler` that will return a HTTP `404` with an HTML page showing the existing contexts deployed on the `Server`. @@ -350,8 +349,8 @@ Note also how adding a `Servlet` or a `Filter` returns a _holder_ object that ca When a request arrives to `ServletContextHandler` the request URI will be matched against the ``Filter``s and ``Servlet`` mappings and only those that match will process the request, as dictated by the Servlet specification. -IMPORTANT: `ServletContextHandler` is a terminal `Handler`, that is it always calls `Request.setHandled(true)` when invoked. -Server applications must be careful when creating the `Handler` tree to put ``ServletContextHandler``s as last ``Handler``s in a `HandlerList` or as children of `ContextHandlerCollection`. +IMPORTANT: `ServletContextHandler` is a terminal `Handler`, that is it always returns `true` from its `process(\...)` method when invoked. +Server applications must be careful when creating the `Handler` tree to put ``ServletContextHandler``s as last ``Handler``s in any `Handler.Collection` or as children of a `ContextHandlerCollection`. // TODO: revise what above, as ServletContextHandler is not a terminal handler. // TODO: introduce the fact that ServletContextHandler can have a class loader that may be used to "isolate" web application classes. diff --git a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler.adoc b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler.adoc index 5ae906339fd..657b77eb328 100644 --- a/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler.adoc +++ b/documentation/jetty-documentation/src/main/asciidoc/programming-guide/server/http/server-http-handler.adoc @@ -16,21 +16,15 @@ An `org.eclipse.jetty.server.Handler` is the component that processes incoming HTTP requests and eventually produces HTTP responses. -``Handler``s can be organized in different ways: +``Handler``s can process the HTTP request themselves, or they can be ``Handler.Container``s that delegate HTTP request processing to one or more contained ``Handler``s. +This allows ``Handler``s to be organised as a tree comprised of: -* in a sequence, where ``Handler``s are invoked one after the other -** `HandlerCollection` invokes _all_ ``Handler``s one after the other -** `HandlerList` invokes ``Handlers``s until one calls `Request.setHandled(true)` to indicate that the request has been handled and no further `Handler` should be invoked -* nested, where one `Handler` invokes the next, nested, `Handler` -** `HandlerWrapper` implements this behavior +* Leaf ``Handler``s that return `true` from the `process(\...)` method, generate a response and succeed the `Callback`. +* A `Handler.Wrapper` can be used to form a chain of ``Handler``s where request, response or callback objects are wrapped in the `process(\...)` method before being passed down the chain. +* A `Handler.Collection` that contains a sequence of ``Handler``s, with each `Handler` being called in sequence until one returns `true` from its `process(\..)` method. +* A specialized `Handler.Container` that may use properties of the request (for example, the URI, or a header, etc.) to select from one or more contained ``Handler``s to delegate the HTTP request processing to. -The `HandlerCollection` behavior (invoking _all_ handlers) is useful when for example the last `Handler` is a logging `Handler` that logs the request (that may have been modified by previous handlers). - -The `HandlerList` behavior (invoking handlers up to the first that calls `Request.setHandled(true)`) is useful when each handler processes a different URIs or a different virtual hosts: ``Handler``s are invoked one after the other until one matches the URI or virtual host. - -The nested behavior is useful to enrich the request with additional services such as HTTP session support (`SessionHandler`), or with specific behaviors dictated by the Servlet specification (`ServletHandler`). - -``Handler``s can be organized in a tree by composing them together: +A `Handler` tree is created by composing ``Handler``s together: [source,java,indent=0] ---- @@ -42,7 +36,7 @@ The corresponding `Handler` tree structure looks like the following: [source,screen] ---- Server -└── LoggingHandler +└── GzipHandler └── Handler.Collection ├── App1Handler └── App2Handler diff --git a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java index 1fd6bf30696..dd1de25c92e 100644 --- a/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java +++ b/documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/server/http/HTTPServerDocs.java @@ -36,6 +36,7 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpHeaderValue; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; +import org.eclipse.jetty.http.HttpURI; import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory; import org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory; import org.eclipse.jetty.http3.server.HTTP3ServerConnectionFactory; @@ -205,7 +206,7 @@ public class HTTPServerDocs ServletContextHandler otherContext = new ServletContextHandler(); mainContext.setContextPath("/other"); - server.setHandler(new HandlerList(requestLogHandler, otherContext)); + server.setHandler(new Handler.Collection(requestLogHandler, otherContext)); */ // end::contextRequestLog[] } @@ -505,14 +506,14 @@ public class HTTPServerDocs } // tag::handlerTree[] - // Create a Server instance. Server server = new Server(); - LoggingHandler loggingHandler = new LoggingHandler(); - // Link the root Handler with the Server. - server.setHandler(loggingHandler); + GzipHandler gzipHandler = new GzipHandler(); + server.setHandler(gzipHandler); Handler.Collection collection = new Handler.Collection(); + gzipHandler.setHandler(collection); + collection.addHandler(new App1Handler()); collection.addHandler(new App2Handler()); // end::handlerTree[] @@ -582,29 +583,32 @@ public class HTTPServerDocs } // tag::handlerFilter[] - // TODO: This needs to be rewritten using a custom Processor -/* - class FilterHandler extends HandlerWrapper + class FilterHandler extends Handler.Wrapper { @Override - public void handle(String target, Request jettyRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException + public boolean process(Request request, Response response, Callback callback) throws Exception { - String path = request.getRequestURI(); + String path = Request.getPathInContext(request); if (path.startsWith("/old_path/")) { // Rewrite old paths to new paths. - HttpURI uri = jettyRequest.getHttpURI(); + HttpURI uri = request.getHttpURI(); String newPath = "/new_path/" + path.substring("/old_path/".length()); - HttpURI newURI = HttpURI.build(uri).path(newPath); - // Modify the request object. - jettyRequest.setHttpURI(newURI); + HttpURI newURI = HttpURI.build(uri).path(newPath).asImmutable(); + + // Modify the request object by wrapping the HttpURI + request = new Request.Wrapper(request) + { + @Override + public HttpURI getHttpURI() + { + return newURI; + } + }; } - // This Handler is not handling the request, so - // it does not call jettyRequest.setHandled(true). - // Forward to the next Handler. - super.handle(target, jettyRequest, request, response); + return super.process(request, response, callback); } } @@ -618,7 +622,6 @@ public class HTTPServerDocs server.setHandler(filter); server.start(); -*/ // end::handlerFilter[] } @@ -999,22 +1002,16 @@ public class HTTPServerDocs { // tag::defaultHandler[] Server server = new Server(); + server.setDefaultHandler(new DefaultHandler(false, true)); + Connector connector = new ServerConnector(server); server.addConnector(connector); - // Create a Handler collection. - Handler.Collection handlerList = new Handler.Collection(); - - // Add as first a ContextHandlerCollection to manage contexts. + // Add a ContextHandlerCollection to manage contexts. ContextHandlerCollection contexts = new ContextHandlerCollection(); - handlerList.addHandler(contexts); - // Add as last a DefaultHandler. - DefaultHandler defaultHandler = new DefaultHandler(); - handlerList.addHandler(defaultHandler); - - // Link the HandlerList to the Server. - server.setHandler(handlerList); + // Link the contexts to the Server. + server.setHandler(contexts); server.start(); // end::defaultHandler[] diff --git a/jetty-core/jetty-deploy/src/test/resources/jetty.xml b/jetty-core/jetty-deploy/src/test/resources/jetty.xml index 4f03d1f3c7a..5afa3f4249a 100644 --- a/jetty-core/jetty-deploy/src/test/resources/jetty.xml +++ b/jetty-core/jetty-deploy/src/test/resources/jetty.xml @@ -93,29 +93,11 @@ --> - - - - - - - - - - - - - - - - - - - + diff --git a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java index 0318127bbde..5490383bae5 100644 --- a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java +++ b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServer.java @@ -228,13 +228,13 @@ public class JettyHttpServer extends com.sun.net.httpserver.HttpServer JettyHttpContext context = new JettyHttpContext(this, path, httpHandler); HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler(); - ContextHandlerCollection chc = _server.getDescendant(ContextHandlerCollection.class); + ContextHandlerCollection contexts = _server.getDescendant(ContextHandlerCollection.class); - if (chc == null) + if (contexts == null) throw new RuntimeException("could not find ContextHandlerCollection, you must configure one"); - chc.addHandler(jettyContextHandler); - if (chc.isStarted()) + contexts.addHandler(jettyContextHandler); + if (contexts.isStarted()) { try { diff --git a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java index bb547ae60ad..b79f9c06bba 100644 --- a/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java +++ b/jetty-core/jetty-http-spi/src/main/java/org/eclipse/jetty/http/spi/JettyHttpServerProvider.java @@ -21,8 +21,6 @@ import com.sun.net.httpserver.HttpsServer; import com.sun.net.httpserver.spi.HttpServerProvider; 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.HandlerList; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ThreadPool; @@ -31,7 +29,6 @@ import org.eclipse.jetty.util.thread.ThreadPool; */ public class JettyHttpServerProvider extends HttpServerProvider { - private static Server _server; public static void setServer(Server server) @@ -51,8 +48,7 @@ public class JettyHttpServerProvider extends HttpServerProvider ThreadPool threadPool = new DelegatingThreadPool(new QueuedThreadPool()); server = new Server(threadPool); - HandlerList handlerCollection = new HandlerList(new ContextHandlerCollection(), new DefaultHandler()); - server.setHandler(handlerCollection); + server.setHandler(new ContextHandlerCollection(true)); shared = false; } diff --git a/jetty-core/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml b/jetty-core/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml index 4c1bfd390b5..c47bd35b10d 100644 --- a/jetty-core/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml +++ b/jetty-core/jetty-rewrite/src/test/resources/org.mortbay.jetty.rewrite.handler/jetty-rewrite.xml @@ -156,18 +156,7 @@ - - - - - - - - - - - - + diff --git a/jetty-core/jetty-server/src/main/config/etc/jetty.xml b/jetty-core/jetty-server/src/main/config/etc/jetty.xml index 4fb1c92b839..c2e286ad0d0 100644 --- a/jetty-core/jetty-server/src/main/config/etc/jetty.xml +++ b/jetty-core/jetty-server/src/main/config/etc/jetty.xml @@ -81,24 +81,17 @@ - - - - - + + + + + + + - - - - - - - - - - - + + diff --git a/jetty-core/jetty-server/src/main/config/modules/server.mod b/jetty-core/jetty-server/src/main/config/modules/server.mod index fca754b7dfb..68ca6dc61c9 100644 --- a/jetty-core/jetty-server/src/main/config/modules/server.mod +++ b/jetty-core/jetty-server/src/main/config/modules/server.mod @@ -111,3 +111,13 @@ etc/jetty.xml ## The number of server scheduler threads. # jetty.scheduler.threads=1 # end::documentation-scheduler-config[] + +## Whether the handlers of the ContextHandlerCollection can be updated once the server is started +## If set to false, then eeN-deploy module jetty.deploy.scanInterval should also be set to 0. +# jetty.server.contexts.dynamic=true + +## Should the DefaultHandler serve the jetty favicon.ico from the root. +# jetty.server.default.serveFavIcon=true + +## Should the DefaultHandler show a list of known contexts in a root 404 response. +# jetty.server.default.showContexts=true diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java index b87493e747f..e6862b0b944 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java @@ -297,9 +297,17 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc { // check state Server server = nested.getServer(); - if (server != null && server.isStarted() && handler != null && - server.getInvocationType() != Invocable.combine(server.getInvocationType(), handler.getInvocationType())) - throw new IllegalArgumentException("Cannot change invocation type of started server"); + + // If the collection is changed whilst started, then the risk is that if we switch from NON_BLOCKING to BLOCKING + // whilst the execution strategy may have already dispatched the very last available thread, thinking it would + // never block, only for it to lose the race and find a newly added BLOCKING handler. + if (server != null && server.isStarted() && handler != null) + { + InvocationType serverInvocationType = server.getInvocationType(); + if (serverInvocationType != Invocable.combine(serverInvocationType, handler.getInvocationType()) && + serverInvocationType != InvocationType.BLOCKING) + throw new IllegalArgumentException("Cannot change invocation type of started server"); + } // Check for loops. if (handler == nested || (handler instanceof Handler.Container container && @@ -401,13 +409,33 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc */ abstract class AbstractContainer extends Abstract implements Container { + private boolean _dynamic; + protected AbstractContainer() { + this(true); } - protected AbstractContainer(InvocationType invocationType) + /** + * @param dynamic If true, then handlers may be added to the container dynamically when started, + * thus the InvocationType is assumed to be BLOCKING, + * otherwise handlers cannot be modified once the container is started. + */ + protected AbstractContainer(boolean dynamic) { - super(invocationType); + _dynamic = dynamic; + } + + public boolean isDynamic() + { + return _dynamic; + } + + public void setDynamic(boolean dynamic) + { + if (isStarted()) + throw new IllegalStateException(getState()); + _dynamic = dynamic; } @Override @@ -468,6 +496,9 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc @Override public InvocationType getInvocationType() { + // Dynamic is always BLOCKING, as a blocking handler can be added at any time. + if (_dynamic) + return InvocationType.BLOCKING; InvocationType invocationType = InvocationType.NON_BLOCKING; for (Handler child : getHandlers()) invocationType = Invocable.combine(invocationType, child.getInvocationType()); @@ -512,8 +543,19 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc this(null); } + public Wrapper(boolean dynamic) + { + this(dynamic, null); + } + public Wrapper(Handler handler) { + this(false, handler); + } + + public Wrapper(boolean dynamic, Handler handler) + { + super(dynamic); _handler = handler == null ? null : Nested.updateHandler(this, handler); } @@ -524,6 +566,8 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc public void setHandler(Handler handler) { + if (!isDynamic() && isStarted()) + throw new IllegalStateException(getState()); _handler = Nested.updateHandler(this, handler); } @@ -544,6 +588,8 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc @Override public InvocationType getInvocationType() { + if (isDynamic()) + return InvocationType.BLOCKING; Handler next = getHandler(); return next == null ? InvocationType.NON_BLOCKING : next.getInvocationType(); } @@ -557,15 +603,32 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc class Collection extends AbstractContainer { private volatile List _handlers = new ArrayList<>(); - private volatile InvocationType _invocationType = InvocationType.BLOCKING; public Collection(Handler... handlers) { - this(List.of(handlers)); + this(handlers.length == 0, List.of(handlers)); + } + + public Collection(boolean dynamic) + { + this(dynamic, Collections.emptyList()); } public Collection(List handlers) { + this(handlers == null || handlers.size() == 0, handlers); + } + + /** + * @param dynamic If true, then handlers may be added dynamically once started, + * so the InvocationType is assumed to be BLOCKING, otherwise + * handlers cannot be modified once started. + * + * @param handlers The handlers to add. + */ + public Collection(boolean dynamic, List handlers) + { + super(dynamic); setHandlers(handlers); } @@ -593,11 +656,14 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc public void setHandlers(List handlers) { + if (!isDynamic() && isStarted()) + throw new IllegalStateException(getState()); + List newHandlers = newHandlers(handlers); Server server = getServer(); - InvocationType invocationType = server == null ? null : server.getInvocationType(); - _invocationType = InvocationType.BLOCKING; // switch to blocking invocation type whilst updating handlers; + InvocationType serverInvocationType = server == null ? null : server.getInvocationType(); + InvocationType invocationType = InvocationType.NON_BLOCKING; // Check for loops && InvocationType changes. for (Handler handler : newHandlers) @@ -609,24 +675,31 @@ public interface Handler extends LifeCycle, Destroyable, Invocable, Request.Proc container.getDescendants().contains(this))) throw new IllegalStateException("setHandler loop"); invocationType = Invocable.combine(invocationType, handler.getInvocationType()); - if (server != null && server.isStarted() && - server.getInvocationType() != Invocable.combine(server.getInvocationType(), handler.getInvocationType())) - throw new IllegalArgumentException("Cannot change invocation type of started server"); - if (server != null) handler.setServer(server); } + // If the collection can be changed dynamically, then the risk is that if we switch from NON_BLOCKING to BLOCKING + // whilst the execution strategy may have already dispatched the very last available thread, thinking it would + // never block, only for it to lose the race and find a newly added BLOCKING handler. + if (isDynamic() && server != null && server.isStarted() && serverInvocationType != invocationType && serverInvocationType != InvocationType.BLOCKING) + throw new IllegalArgumentException("Cannot change invocation type of started server"); + updateBeans(_handlers, handlers); _handlers = newHandlers; - _invocationType = invocationType; } @Override public InvocationType getInvocationType() { - return _invocationType == null ? super.getInvocationType() : _invocationType; + if (isDynamic()) + return InvocationType.BLOCKING; + + InvocationType invocationType = InvocationType.NON_BLOCKING; + for (Handler handler : _handlers) + invocationType = Invocable.combine(invocationType, handler.getInvocationType()); + return invocationType; } protected List newHandlers(List handlers) diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java index 37d5b385dcc..5c17a91ddf6 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java @@ -39,6 +39,7 @@ import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ErrorProcessor; import org.eclipse.jetty.util.Attributes; +import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.ExceptionUtil; import org.eclipse.jetty.util.IO; @@ -56,6 +57,7 @@ import org.eclipse.jetty.util.resource.FileSystemPool; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; import org.eclipse.jetty.util.thread.AutoLock; +import org.eclipse.jetty.util.thread.Invocable; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.ShutdownThread; import org.eclipse.jetty.util.thread.ThreadPool; @@ -77,6 +79,7 @@ public class Server extends Handler.Wrapper implements Attributes private boolean _stopAtShutdown; private boolean _dumpAfterStart; private boolean _dumpBeforeStop; + private Handler _defaultHandler; private Request.Processor _errorProcessor; private RequestLog _requestLog; private boolean _dryRun; @@ -130,6 +133,31 @@ public class Server extends Handler.Wrapper implements Attributes addBean(FileSystemPool.INSTANCE, false); } + public Handler getDefaultHandler() + { + return _defaultHandler; + } + + /** + * @param defaultHandler The handler to use if no other handler is set or has processed the request. This handler should + * always accept the request, even if only to send a 404. + */ + public void setDefaultHandler(Handler defaultHandler) + { + if (!isDynamic() && isStarted()) + throw new IllegalStateException(getState()); + Handler old = _defaultHandler; + _defaultHandler = defaultHandler; + updateBean(old, defaultHandler); + } + + @Override + public boolean process(Request request, Response response, Callback callback) throws Exception + { + // Handle either with normal handler or default handler + return super.process(request, response, callback) || _defaultHandler != null && _defaultHandler.process(request, response, callback); + } + public String getServerInfo() { return _serverInfo; @@ -195,11 +223,22 @@ public class Server extends Handler.Wrapper implements Attributes @Override public InvocationType getInvocationType() { - Handler handler = getHandler(); - if (handler == null) - return InvocationType.NON_BLOCKING; + if (isDynamic()) + return InvocationType.BLOCKING; + // Return cached type to avoid a full handler tree walk. - return isRunning() ? _invocationType : handler.getInvocationType(); + if (isStarted()) + return _invocationType; + + InvocationType type = InvocationType.NON_BLOCKING; + Handler handler = getHandler(); + if (handler != null) + type = Invocable.combine(type, handler.getInvocationType()); + handler = getDefaultHandler(); + if (handler != null) + type = Invocable.combine(type, handler.getInvocationType()); + + return type; } public boolean isDryRun() @@ -475,8 +514,7 @@ public class Server extends Handler.Wrapper implements Attributes // Cache the invocation type to avoid runtime walk of handler tree // Handlers must check they don't change the InvocationType of a started server - Handler handler = getHandler(); - _invocationType = handler == null ? InvocationType.NON_BLOCKING : handler.getInvocationType(); + _invocationType = getInvocationType(); if (_dryRun) { diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java index 62557824389..04ea66642e3 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandlerCollection.java @@ -50,6 +50,19 @@ public class ContextHandlerCollection extends Handler.Collection public ContextHandlerCollection(ContextHandler... contexts) { + this(true, contexts); + } + + /** + * @param dynamic If true, then contexts may be added dynamically once started, + * so the InvocationType is assumed to be BLOCKING, otherwise + * the InvocationType is fixed once started and handlers cannot be + * subsequently added. + * @param contexts The contexts to add. + */ + public ContextHandlerCollection(boolean dynamic, ContextHandler... contexts) + { + super(dynamic); if (contexts.length > 0) setHandlers(contexts); } diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java index c97d1747c09..d1828644383 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/DefaultHandler.java @@ -38,6 +38,7 @@ import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; +import org.eclipse.jetty.util.annotation.Name; import org.eclipse.jetty.util.resource.Resource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,11 +60,19 @@ public class DefaultHandler extends Handler.Abstract private final long _faviconModifiedMs = (System.currentTimeMillis() / 1000) * 1000L; private final HttpField _faviconModified = new PreEncodedHttpField(HttpHeader.LAST_MODIFIED, DateGenerator.formatDate(_faviconModifiedMs)); private ByteBuffer _favicon; - private boolean _serveIcon = true; + private boolean _serveFavIcon = true; private boolean _showContexts = true; public DefaultHandler() { + this(true, true); + } + + public DefaultHandler(@Name("serveFavIcon") boolean serveFavIcon, @Name("showContexts")boolean showContexts) + { + super(InvocationType.NON_BLOCKING); + _serveFavIcon = serveFavIcon; + _showContexts = showContexts; } @Override @@ -109,7 +118,7 @@ public class DefaultHandler extends Handler.Abstract String method = request.getMethod(); // little cheat for common request - if (isServeIcon() && _favicon != null && HttpMethod.GET.is(method) && Request.getPathInContext(request).equals("/favicon.ico")) + if (isServeFavIcon() && _favicon != null && HttpMethod.GET.is(method) && Request.getPathInContext(request).equals("/favicon.ico")) { ByteBuffer content = BufferUtil.EMPTY_BUFFER; if (_faviconModifiedMs > 0 && request.getHeaders().getDateField(HttpHeader.IF_MODIFIED_SINCE) == _faviconModifiedMs) @@ -218,18 +227,18 @@ public class DefaultHandler extends Handler.Abstract /** * @return Returns true if the handle can server the jetty favicon.ico */ - @ManagedAttribute("True if the favicon.ico should be served") - public boolean isServeIcon() + @ManagedAttribute("True if the favicon.ico is served") + public boolean isServeFavIcon() { - return _serveIcon; + return _serveFavIcon; } /** - * @param serveIcon true if the handle can server the jetty favicon.ico + * @param serveFavIcon true if the handle can server the jetty favicon.ico */ - public void setServeIcon(boolean serveIcon) + public void setServeFavIcon(boolean serveFavIcon) { - _serveIcon = serveIcon; + _serveFavIcon = serveFavIcon; } @ManagedAttribute("True if the contexts should be shown in the default 404 page") diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerList.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerList.java deleted file mode 100644 index ed759314bfd..00000000000 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerList.java +++ /dev/null @@ -1,33 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.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.server.handler; - -import org.eclipse.jetty.server.Handler; - -/** - * HandlerList. - * @deprecated - */ -@Deprecated -public class HandlerList extends Handler.Collection -{ - public HandlerList() - { - } - - public HandlerList(Handler... handlers) - { - super(handlers); - } -} diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java deleted file mode 100644 index a94c7f7e5d0..00000000000 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HandlerWrapper.java +++ /dev/null @@ -1,26 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.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.server.handler; - -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.util.annotation.ManagedObject; - -/** - * @deprecated Use {@link Handler.Wrapper} - */ -@ManagedObject("Handler wrapping another Handler") -@Deprecated -public class HandlerWrapper extends Handler.Wrapper -{ -} diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java index 80725440e23..45e1f25e768 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/HotSwapHandler.java @@ -37,6 +37,7 @@ public class HotSwapHandler extends Handler.AbstractContainer implements Handler */ public HotSwapHandler() { + super(true); } /** diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/PathMappingsHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/PathMappingsHandler.java index 310931bbd08..9bf81190435 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/PathMappingsHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/PathMappingsHandler.java @@ -39,6 +39,16 @@ public class PathMappingsHandler extends Handler.AbstractContainer private final PathMappings mappings = new PathMappings<>(); + public PathMappingsHandler() + { + this(true); + } + + public PathMappingsHandler(boolean dynamic) + { + super(dynamic); + } + @Override public void addHandler(Handler handler) { diff --git a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java index b484442a039..9cc4c17caf3 100644 --- a/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java +++ b/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ShutdownHandler.java @@ -41,10 +41,9 @@ import org.slf4j.LoggerFactory; * *
  * Server server = new Server(8080);
- * HandlerList handlers = new HandlerList();
- * handlers.setHandlers(new Handler[]
- * { someOtherHandler, new ShutdownHandler("secret password", false, true) });
- * server.setHandler(handlers);
+ * ShutdownHandler shutdown = new ShutdownHandler("secret password", false, true) });
+ * server.setHandler(shutdown);
+ * shutdown.setHandler(someOtherHandler);
  * server.start();
  * 
* @@ -151,7 +150,7 @@ public class ShutdownHandler extends Handler.Wrapper @Override public boolean process(Request request, Response response, Callback callback) throws Exception { - return false; + return super.process(request, response, callback); /* TODO if (!target.equals("/shutdown")) { diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java index 42fa6f0d7d5..5790eecd144 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/PartialRFC2616Test.java @@ -24,7 +24,6 @@ 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.DumpHandler; -import org.eclipse.jetty.server.handler.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; @@ -39,7 +38,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -@Disabled // TODO public class PartialRFC2616Test { private Server server; @@ -62,7 +60,7 @@ public class PartialRFC2616Test context.setContextPath("/"); context.setHandler(new DumpHandler()); - server.setHandler(new HandlerList(vcontext, context)); + server.setHandler(new Handler.Collection(vcontext, context)); server.start(); } @@ -406,6 +404,7 @@ public class PartialRFC2616Test } @Test + @Disabled // TODO public void test521() throws Exception { // Default Host @@ -413,7 +412,7 @@ public class PartialRFC2616Test String response = connector.getResponse("GET http://VirtualHost:8888/path/R1 HTTP/1.1\n" + "Host: wronghost\n" + "Connection: close\n" + "\n"); offset = checkContains(response, offset, "HTTP/1.1 200", "Virtual host") + 1; offset = checkContains(response, offset, "Virtual Dump", "Virtual host") + 1; - offset = checkContains(response, offset, "pathInfo=/path/R1", "Virtual host") + 1; + offset = checkContains(response, offset, "pathInContext=/path/R1", "Virtual host") + 1; offset = checkContains(response, offset, "servername=VirtualHost", "Virtual host") + 1; } @@ -424,15 +423,15 @@ public class PartialRFC2616Test int offset = 0; String response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: localhost\n" + "Connection: close\n" + "\n"); offset = checkContains(response, offset, "HTTP/1.1 200", "Default host") + 1; - offset = checkContains(response, offset, "Dump HttpHandler", "Default host") + 1; - offset = checkContains(response, offset, "pathInfo=/path/R1", "Default host") + 1; + offset = checkContains(response, offset, "Dump Handler", "Default host") + 1; + offset = checkContains(response, offset, "pathInContext=/path/R1", "Default host") + 1; // Virtual Host offset = 0; response = connector.getResponse("GET /path/R2 HTTP/1.1\n" + "Host: VirtualHost\n" + "Connection: close\n" + "\n"); offset = checkContains(response, offset, "HTTP/1.1 200", "Default host") + 1; offset = checkContains(response, offset, "Virtual Dump", "virtual host") + 1; - offset = checkContains(response, offset, "pathInfo=/path/R2", "Default host") + 1; + offset = checkContains(response, offset, "pathInContext=/path/R2", "Default host") + 1; } @Test @@ -443,14 +442,14 @@ public class PartialRFC2616Test String response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: VirtualHost\n" + "Connection: close\n" + "\n"); offset = checkContains(response, offset, "HTTP/1.1 200", "2. virtual host field") + 1; offset = checkContains(response, offset, "Virtual Dump", "2. virtual host field") + 1; - offset = checkContains(response, offset, "pathInfo=/path/R1", "2. virtual host field") + 1; + offset = checkContains(response, offset, "pathInContext=/path/R1", "2. virtual host field") + 1; // Virtual Host case insensitive offset = 0; response = connector.getResponse("GET /path/R1 HTTP/1.1\n" + "Host: ViRtUalhOst\n" + "Connection: close\n" + "\n"); offset = checkContains(response, offset, "HTTP/1.1 200", "2. virtual host field") + 1; offset = checkContains(response, offset, "Virtual Dump", "2. virtual host field") + 1; - offset = checkContains(response, offset, "pathInfo=/path/R1", "2. virtual host field") + 1; + offset = checkContains(response, offset, "pathInContext=/path/R1", "2. virtual host field") + 1; // Virtual Host offset = 0; @@ -486,6 +485,7 @@ public class PartialRFC2616Test } @Test + @Disabled // TODO public void test10418() throws Exception { // Expect Failure @@ -541,6 +541,7 @@ public class PartialRFC2616Test } @Test + @Disabled // TODO public void test824() throws Exception { // Expect 100 not sent @@ -599,6 +600,7 @@ public class PartialRFC2616Test } @Test + @Disabled // TODO public void test1423() throws Exception { try (StacklessLogging stackless = new StacklessLogging(HttpParser.class)) diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java index 93dc6ad52d7..e55a979a338 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ContextHandlerCollectionTest.java @@ -285,7 +285,7 @@ public class ContextHandlerCollectionTest String rawResponse = connector.getResponse(rawRequest); HttpTester.Response response = HttpTester.parseResponse(rawResponse); assertThat("Response status for [GET " + requestHost + "]", response.getStatus(), is(HttpStatus.NOT_FOUND_404)); - assertThat("Response body for [GET " + requestHost + "]", response.getContent(), containsString("

HTTP ERROR 404 Not Found

")); + assertThat("Response body for [GET " + requestHost + "]", response.getContent(), containsString("Not Found")); assertThat("Response Header for [GET " + requestHost + "]", response.get("X-IsHandled-Name"), nullValue()); connector.getResponse(rawRequest); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java index 0ecb8ac30c0..de4d627b231 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/DefaultHandlerTest.java @@ -48,11 +48,7 @@ public class DefaultHandlerTest server.addConnector(connector); ContextHandlerCollection contexts = new ContextHandlerCollection(); - handler = new DefaultHandler(); - server.setHandler(new Handler.Collection(contexts, handler)); - - handler.setServeIcon(true); - handler.setShowContexts(true); + server.setHandler(new Handler.Collection(contexts, new DefaultHandler(true, true))); contexts.addHandler(new ContextHandler("/foo")); contexts.addHandler(new ContextHandler("/bar")); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java index 65fd6f66315..c98b162aff6 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java @@ -400,7 +400,7 @@ public class NcsaRequestLogTest setup(logType); RequestLogHandler handler = new RequestLogHandler(); handler.setRequestLog(_log); - HandlerList handlers = new HandlerList(handler, testHandler); + Handler.Collection handlers = new Handler.Collection(handler, testHandler); _server.setHandler(handlers); startServer(); makeRequest(requestPath); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java index 13807825810..6a8f2aac41f 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ResourceHandlerTest.java @@ -355,7 +355,7 @@ public class ResourceHandlerTest (response) -> { String body = response.getContent(); - assertThat(body, containsString("/../../")); + assertThat(body, containsString("Not Found")); assertThat(body, not(containsString("Directory: "))); } ); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerCodeTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerCodeTest.java index 306f6cc206f..f32e79c3888 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerCodeTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerCodeTest.java @@ -149,7 +149,7 @@ public class SecuredRedirectHandlerCodeTest contextHandlers.setHandlers(redirectHandler); // Create server level handler tree - server.setHandler(new HandlerList(contextHandlers, new DefaultHandler())); + server.setHandler(contextHandlers); server.start(); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java index 3efb7623c5b..a3a5f579b9a 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/SecuredRedirectHandlerTest.java @@ -118,7 +118,7 @@ public class SecuredRedirectHandlerTest contextHandlers.setHandlers(redirectHandler, rootContext, test1Context, test2Context); // Create server level handler tree - server.setHandler(new HandlerList(contextHandlers, new DefaultHandler())); + server.setHandler(contextHandlers); server.start(); diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java index beef6dbf64f..693f4c688c2 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/handler/ShutdownHandlerTest.java @@ -40,7 +40,7 @@ public class ShutdownHandlerTest private ServerConnector connector; private String shutdownToken = "asdlnsldgnklns"; - public void start(HandlerWrapper wrapper) throws Exception + public void start(Handler.Wrapper wrapper) throws Exception { server = new Server(); connector = new ServerConnector(server); @@ -94,7 +94,7 @@ public class ShutdownHandlerTest public void testShutdownRequestNotFromLocalhost() throws Exception { /* TODO - start(new HandlerWrapper() + start(new Handler.Wrapper() { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/exampleserver.xml b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/exampleserver.xml index 0a32e6d0465..8e86cdfec1c 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/exampleserver.xml +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/exampleserver.xml @@ -16,26 +16,20 @@ - - /hello - - org.eclipse.jetty.ee10.demos.HelloServlet - / - - - - - - - - - - - - - - + + + + + + /hello + + org.eclipse.jetty.ee10.demos.HelloServlet + / + + + + diff --git a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/fileserver.xml b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/fileserver.xml index e8144221be0..cf7086184e8 100644 --- a/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/fileserver.xml +++ b/jetty-ee10/jetty-ee10-demos/jetty-ee10-demo-embedded/src/main/resources/fileserver.xml @@ -13,25 +13,13 @@ - - - - - - - - true - - index.html - - - - - - - - - - - + + + + true + + index.html + + + diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/test/resources/embedder-jetty.xml b/jetty-ee10/jetty-ee10-maven-plugin/src/test/resources/embedder-jetty.xml index 556046aa2d7..08157651885 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/test/resources/embedder-jetty.xml +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/test/resources/embedder-jetty.xml @@ -2,24 +2,15 @@ - - - - - - - - - - - - - - + + + + + - - - - + + + + diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-with-custom-class.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-with-custom-class.xml index 420640353c8..3dd28c47ebf 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-with-custom-class.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-with-custom-class.xml @@ -26,18 +26,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty.xml index 4e8ac736b60..dde7ec29432 100644 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty.xml +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty.xml @@ -24,18 +24,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java index 0ddee88f605..a1ddc7b3adc 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/DefaultServletTest.java @@ -768,7 +768,7 @@ public class DefaultServletTest (response) -> { String body = response.getContent(); - assertThat(body, containsString("/../../")); + assertThat(body, containsString("Not Found")); assertThat(body, not(containsString("Directory: "))); } ); diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/security/AliasedConstraintTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/security/AliasedConstraintTest.java index e49fa0c1d39..e36f9a451cc 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/security/AliasedConstraintTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/security/AliasedConstraintTest.java @@ -25,8 +25,6 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.security.Constraint; @@ -75,7 +73,7 @@ public class AliasedConstraintTest context.setContextPath("/ctx"); context.setBaseResourceAsPath(MavenTestingUtils.getTestResourcePathDir("docroot")); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); server.addBean(loginService); diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml index 244827d5936..41695e90032 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/DefaultHandler.xml @@ -20,24 +20,19 @@ - - - - - - - - - /tests - /default - - - - default - - - - + + + + + /tests + /default + + + + default + + + diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml index 27203314f2b..9f6af74dd8e 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/RFC2616Base.xml @@ -33,42 +33,39 @@ - - - - - - - - - /tests - - - VirtualHost - - - /virtualhost - - virtual - - - - - /tests - /default - - default - - - - - /echo - - echo - - - - + + + + + + /tests + + + VirtualHost + + + /virtualhost + + virtual + + + + + /tests + /default + + default + + + + + /echo + + echo + + + + diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/add-jetty-test-webapp.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/add-jetty-test-webapp.xml index 197c7fe1c5d..1196a26b630 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/add-jetty-test-webapp.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/add-jetty-test-webapp.xml @@ -1,7 +1,7 @@ - + /test-jetty-webapp diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/basic-server.xml b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/basic-server.xml index 74283e41641..ea263cbb9d1 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/basic-server.xml +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-integration/src/test/resources/basic-server.xml @@ -19,18 +19,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/CoreServer.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/CoreServer.java index 6da2d3e30a8..a7c8edb29b0 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/CoreServer.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/CoreServer.java @@ -20,8 +20,6 @@ import org.eclipse.jetty.ee10.websocket.jakarta.tests.framehandlers.FrameEcho; import org.eclipse.jetty.ee10.websocket.jakarta.tests.framehandlers.WholeMessageEcho; 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.HandlerList; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -61,7 +59,7 @@ public class CoreServer extends ContainerLifeCycle // Add Handler WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(); upgradeHandler.addMapping("/*", negotiator); - server.setHandler(new HandlerList(upgradeHandler, new DefaultHandler())); + server.setHandler(upgradeHandler); // Start Server addBean(server); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/RestartContextTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/RestartContextTest.java index 73c14063953..461f18a29cc 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/RestartContextTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee10/websocket/jakarta/tests/RestartContextTest.java @@ -32,8 +32,6 @@ import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketSe import org.eclipse.jetty.ee10.websocket.jakarta.server.internal.JakartaWebSocketServerContainer; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -67,7 +65,7 @@ public class RestartContextTest context.addEventListener(new AddEndpointListener()); // Setup handler tree - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); // Start server server.start(); @@ -103,11 +101,8 @@ public class RestartContextTest serverContainer.addEndpoint(EchoEndpoint.class); }); - // Setup handler tree - HandlerList handlers = new HandlerList(context, new DefaultHandler()); - // Add handler tree to server - server.setHandler(handlers); + server.setHandler(context); // Start server server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee10/websocket/server/browser/BrowserDebugTool.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee10/websocket/server/browser/BrowserDebugTool.java index ad72916d8ab..6412888210f 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee10/websocket/server/browser/BrowserDebugTool.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee10/websocket/server/browser/BrowserDebugTool.java @@ -34,8 +34,6 @@ import org.eclipse.jetty.ee10.websocket.server.JettyWebSocketServletFactory; import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer; 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.HandlerList; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; @@ -109,7 +107,7 @@ public class BrowserDebugTool ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); context.addServlet(defHolder, "/"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); LOG.info("{} setup on port {}", this.getClass().getName(), port); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/BadNetworkTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/BadNetworkTest.java index 9b7d66a51e7..26a3898fb6c 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/BadNetworkTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/BadNetworkTest.java @@ -32,8 +32,6 @@ import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletConta import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -81,7 +79,7 @@ public class BadNetworkTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientCloseTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientCloseTest.java index 6b2e4b18569..e3eae4c1cb4 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientCloseTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientCloseTest.java @@ -41,8 +41,6 @@ import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; 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.HandlerList; import org.eclipse.jetty.util.BlockingArrayQueue; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.OpCode; @@ -131,7 +129,7 @@ public class ClientCloseTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientSessionsTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientSessionsTest.java index 27e173fec6d..4323b460e3b 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientSessionsTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/ClientSessionsTest.java @@ -36,8 +36,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.ee10.websocket.tests.EchoCreator; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -74,7 +72,7 @@ public class ClientSessionsTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/SlowClientTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/SlowClientTest.java index 9e3824e3b6e..007bda2a75c 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/SlowClientTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/client/SlowClientTest.java @@ -30,8 +30,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.ee10.websocket.tests.EchoSocket; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,7 +74,7 @@ public class SlowClientTest }); context.addServlet(websocket, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameAnnotationTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameAnnotationTest.java index af24dab8dea..871ec169482 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameAnnotationTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameAnnotationTest.java @@ -43,8 +43,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.AfterEach; @@ -85,7 +83,7 @@ public class FrameAnnotationTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); server.start(); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameListenerTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameListenerTest.java index 04a737587d6..e583ca16293 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameListenerTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/FrameListenerTest.java @@ -36,8 +36,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.AfterEach; @@ -78,7 +76,7 @@ public class FrameListenerTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); server.start(); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/PartialListenerTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/PartialListenerTest.java index edd1411cb7f..a61ac408453 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/PartialListenerTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/PartialListenerTest.java @@ -39,8 +39,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import org.junit.jupiter.api.AfterEach; @@ -81,7 +79,7 @@ public class PartialListenerTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); server.start(); } diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/ServerCloseTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/ServerCloseTest.java index e67d3fd5e7a..aebd734f41d 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/ServerCloseTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/ServerCloseTest.java @@ -33,8 +33,6 @@ import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -80,7 +78,7 @@ public class ServerCloseTest }); context.addServlet(closeEndpoint, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/SlowServerTest.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/SlowServerTest.java index 95e0cf6e357..241148eec5a 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/SlowServerTest.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee10/websocket/tests/server/SlowServerTest.java @@ -29,8 +29,6 @@ import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletConta import org.eclipse.jetty.ee10.websocket.tests.CloseTrackingEndpoint; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,7 +74,7 @@ public class SlowServerTest }); context.addServlet(websocket, "/ws"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-ant/src/main/java/org/eclipse/jetty/ee9/ant/ServerProxyImpl.java b/jetty-ee9/jetty-ee9-ant/src/main/java/org/eclipse/jetty/ee9/ant/ServerProxyImpl.java index ab9b2e7cef2..96a8c063b09 100644 --- a/jetty-ee9/jetty-ee9-ant/src/main/java/org/eclipse/jetty/ee9/ant/ServerProxyImpl.java +++ b/jetty-ee9/jetty-ee9-ant/src/main/java/org/eclipse/jetty/ee9/ant/ServerProxyImpl.java @@ -34,7 +34,6 @@ 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; @@ -408,7 +407,7 @@ public class ServerProxyImpl implements ServerProxy contexts = new ContextHandlerCollection(); HandlerCollection handlers = server.getChildHandlerByClass(HandlerCollection.class); if (handlers == null) - server.setHandler(new HandlerList(contexts, new DefaultHandler())); + server.setHandler(contexts); else handlers.addHandler(contexts); } diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/FastFileServer.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/FastFileServer.java index 7fd9c29bb58..3e86856ddb7 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/FastFileServer.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/FastFileServer.java @@ -20,8 +20,6 @@ import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.DefaultHandler; -import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.util.Callback; @@ -59,9 +57,7 @@ public class FastFileServer { Server server = new Server(port); - server.setHandler(new HandlerList( - new FastFileHandler(resourceBase), - new DefaultHandler())); + server.setHandler(new FastFileHandler(resourceBase)); return server; } diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/JarServer.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/JarServer.java index 9a0d893ef61..39119aba5fd 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/JarServer.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/JarServer.java @@ -25,9 +25,7 @@ import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; 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.HandlerList; import org.eclipse.jetty.util.FileID; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.util.resource.Resource; diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/LikeJettyXml.java b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/LikeJettyXml.java index 7f3c601196c..9b078f285a9 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/LikeJettyXml.java +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/java/org/eclipse/jetty/ee9/demos/LikeJettyXml.java @@ -51,7 +51,7 @@ public class LikeJettyXml // // // Handler Structure // ContextHandlerCollection contexts = new ContextHandlerCollection(); -// server.setHandler(new HandlerList(contexts, new DefaultHandler())); +// server.setHandler(contexts); // // // === jetty-jmx.xml === // MBeanContainer mbContainer = new MBeanContainer( diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/exampleserver.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/exampleserver.xml index 9ca077aa150..b7c4f29aad2 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/exampleserver.xml +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/exampleserver.xml @@ -16,27 +16,13 @@ - - /hello - - org.eclipse.jetty.ee9.demos.HelloServlet - / - - - - - - - - - - - - - - - + + /hello + + org.eclipse.jetty.ee9.demos.HelloServlet + / + diff --git a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/fileserver.xml b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/fileserver.xml index da52d292731..d2cb62cfa18 100644 --- a/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/fileserver.xml +++ b/jetty-ee9/jetty-ee9-demos/jetty-ee9-demo-embedded/src/main/resources/fileserver.xml @@ -13,27 +13,15 @@ - - - - - - - - true - - - index.html - - - - - - - - - - - - + + + + true + + + index.html + + + + diff --git a/jetty-ee9/jetty-ee9-maven-plugin/src/test/resources/embedder-jetty.xml b/jetty-ee9/jetty-ee9-maven-plugin/src/test/resources/embedder-jetty.xml index 653542f48b5..064606b6b42 100644 --- a/jetty-ee9/jetty-ee9-maven-plugin/src/test/resources/embedder-jetty.xml +++ b/jetty-ee9/jetty-ee9-maven-plugin/src/test/resources/embedder-jetty.xml @@ -3,23 +3,11 @@ - - - - - - - - - - - - + - diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ShutdownHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ShutdownHandler.java deleted file mode 100644 index a73e706d77d..00000000000 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ShutdownHandler.java +++ /dev/null @@ -1,265 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License v. 2.0 which is available at -// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.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.ee9.nested; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.InetSocketAddress; -import java.net.SocketException; -import java.net.URL; - -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.eclipse.jetty.server.Connector; -import org.eclipse.jetty.server.NetworkConnector; -import org.eclipse.jetty.server.Server; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A handler that shuts the server down on a valid request. Used to do "soft" restarts from Java. - * If _exitJvm is set to true a hard System.exit() call is being made. - * If _sendShutdownAtStart is set to true, starting the server will try to shut down an existing server at the same port. - * If _sendShutdownAtStart is set to true, make an http call to - * "http://localhost:" + port + "/shutdown?token=" + shutdownCookie - * in order to shut down the server. - * - * This handler is a contribution from Johannes Brodwall: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357687 - * - * Usage: - * - *
- * Server server = new Server(8080);
- * HandlerList handlers = new HandlerList();
- * handlers.setHandlers(new Handler[]
- * { someOtherHandler, new ShutdownHandler("secret password", false, true) });
- * server.setHandler(handlers);
- * server.start();
- * 
- * - *
- * public static void attemptShutdown(int port, String shutdownCookie) {
- * try {
- * URL url = new URL("http://localhost:" + port + "/shutdown?token=" + shutdownCookie);
- * HttpURLConnection connection = (HttpURLConnection)url.openConnection();
- * connection.setRequestMethod("POST");
- * connection.getResponseCode();
- * logger.info("Shutting down " + url + ": " + connection.getResponseMessage());
- * } catch (SocketException e) {
- * logger.debug("Not running");
- * // Okay - the server is not running
- * } catch (IOException e) {
- * throw new RuntimeException(e);
- * }
- * }
- * 
- */ -public class ShutdownHandler extends HandlerWrapper -{ - private static final Logger LOG = LoggerFactory.getLogger(ShutdownHandler.class); - - private final String _shutdownToken; - private boolean _sendShutdownAtStart; - private boolean _exitJvm = false; - - /** - * Creates a listener that lets the server be shut down remotely (but only from localhost). - * - * @param shutdownToken a secret password to avoid unauthorized shutdown attempts - */ - public ShutdownHandler(String shutdownToken) - { - this(shutdownToken, false, false); - } - - /** - * @param shutdownToken a secret password to avoid unauthorized shutdown attempts - * @param exitJVM If true, when the shutdown is executed, the handler class System.exit() - * @param sendShutdownAtStart If true, a shutdown is sent as an HTTP post - * during startup, which will shutdown any previously running instances of - * this server with an identically configured ShutdownHandler - */ - public ShutdownHandler(String shutdownToken, boolean exitJVM, boolean sendShutdownAtStart) - { - this._shutdownToken = shutdownToken; - setExitJvm(exitJVM); - setSendShutdownAtStart(sendShutdownAtStart); - } - - public void sendShutdown() throws IOException - { - URL url = new URL(getServerUrl() + "/shutdown?token=" + _shutdownToken); - try - { - HttpURLConnection connection = (HttpURLConnection)url.openConnection(); - connection.setRequestMethod("POST"); - connection.getResponseCode(); - LOG.info("Shutting down {}: {} {}", url, connection.getResponseCode(), connection.getResponseMessage()); - } - catch (SocketException e) - { - LOG.debug("Not running"); - // Okay - the server is not running - } - catch (IOException e) - { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("resource") - private String getServerUrl() - { - NetworkConnector connector = null; - for (Connector c : getServer().getConnectors()) - { - if (c instanceof NetworkConnector) - { - connector = (NetworkConnector)c; - break; - } - } - - if (connector == null) - return "http://localhost"; - - return "http://localhost:" + connector.getPort(); - } - - @Override - protected void doStart() throws Exception - { - super.doStart(); - if (_sendShutdownAtStart) - sendShutdown(); - } - - @Override - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException - { - if (!target.equals("/shutdown")) - { - super.handle(target, baseRequest, request, response); - return; - } - - if (!request.getMethod().equals("POST")) - { - response.sendError(HttpServletResponse.SC_BAD_REQUEST); - return; - } - if (!hasCorrectSecurityToken(request)) - { - LOG.warn("Unauthorized tokenless shutdown attempt from {}", request.getRemoteAddr()); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - return; - } - if (!requestFromLocalhost(baseRequest)) - { - LOG.warn("Unauthorized non-loopback shutdown attempt from {}", request.getRemoteAddr()); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - return; - } - - LOG.info("Shutting down by request from {}", request.getRemoteAddr()); - doShutdown(baseRequest, response); - } - - protected void doShutdown(Request baseRequest, HttpServletResponse response) throws IOException - { - for (Connector connector : getServer().getConnectors()) - { - connector.shutdown(); - } - - baseRequest.setHandled(true); - response.setStatus(200); - response.flushBuffer(); - - final Server server = getServer(); - new Thread() - { - @Override - public void run() - { - try - { - shutdownServer(server); - } - catch (InterruptedException e) - { - LOG.trace("IGNORED", e); - } - catch (Exception e) - { - throw new RuntimeException("Shutting down server", e); - } - } - }.start(); - } - - private boolean requestFromLocalhost(Request request) - { - InetSocketAddress addr = request.getRemoteInetSocketAddress(); - if (addr == null) - { - return false; - } - return addr.getAddress().isLoopbackAddress(); - } - - private boolean hasCorrectSecurityToken(HttpServletRequest request) - { - String tok = request.getParameter("token"); - if (LOG.isDebugEnabled()) - LOG.debug("Token: {}", tok); - return _shutdownToken.equals(tok); - } - - private void shutdownServer(Server server) throws Exception - { - server.stop(); - - if (_exitJvm) - { - System.exit(0); - } - } - - public void setExitJvm(boolean exitJvm) - { - this._exitJvm = exitJvm; - } - - public boolean isSendShutdownAtStart() - { - return _sendShutdownAtStart; - } - - public void setSendShutdownAtStart(boolean sendShutdownAtStart) - { - _sendShutdownAtStart = sendShutdownAtStart; - } - - public String getShutdownToken() - { - return _shutdownToken; - } - - public boolean isExitJvm() - { - return _exitJvm; - } -} diff --git a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/jettyhome/etc/jetty.xml b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/jettyhome/etc/jetty.xml index 00bd315b460..b395642ab68 100644 --- a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/jettyhome/etc/jetty.xml +++ b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot/jettyhome/etc/jetty.xml @@ -23,18 +23,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty-with-custom-class.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty-with-custom-class.xml index d145ba6f8ce..6c5b989c592 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty-with-custom-class.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty-with-custom-class.xml @@ -26,18 +26,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty.xml index 4e8ac736b60..dde7ec29432 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/jetty.xml @@ -24,18 +24,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee9/jetty-ee9-runner/src/main/java/org/eclipse/jetty/ee9/runner/Runner.java b/jetty-ee9/jetty-ee9-runner/src/main/java/org/eclipse/jetty/ee9/runner/Runner.java index c2340a866ac..6ffa286863d 100644 --- a/jetty-ee9/jetty-ee9-runner/src/main/java/org/eclipse/jetty/ee9/runner/Runner.java +++ b/jetty-ee9/jetty-ee9-runner/src/main/java/org/eclipse/jetty/ee9/runner/Runner.java @@ -49,7 +49,6 @@ 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.session.SessionHandler; import org.eclipse.jetty.util.RolloverFileOutputStream; diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ServletRequestLogTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ServletRequestLogTest.java index f5b0cbd2fbb..449d1c4fa7c 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ServletRequestLogTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/ServletRequestLogTest.java @@ -36,7 +36,6 @@ import org.eclipse.jetty.ee9.nested.Request; import org.eclipse.jetty.ee9.nested.Response; import org.eclipse.jetty.logging.StacklessLogging; 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.ServerConnector; @@ -277,15 +276,14 @@ public class ServletRequestLogTest } /** - * Test a RequestLogHandler at the end of a HandlerCollection. - * This handler chain is setup to look like Jetty versions up to 9.2. + * Test a RequestLog * Default configuration. * * @throws Exception on test failure */ @ParameterizedTest @MethodSource("data") - public void testLogHandlerCollection(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception + public void testLogHandler(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception { Server server = new Server(); ServerConnector connector = new ServerConnector(server); @@ -293,15 +291,9 @@ public class ServletRequestLogTest server.setConnectors(new Connector[]{connector}); // First the behavior as defined in etc/jetty.xml - // id="Handlers" - org.eclipse.jetty.server.Handler.Collection handlers = new org.eclipse.jetty.server.Handler.Collection(); - // id="Contexts" ContextHandlerCollection contexts = new ContextHandlerCollection(); - // id="DefaultHandler" - DefaultHandler defaultHandler = new DefaultHandler(); - - handlers.setHandlers(contexts, defaultHandler); - server.setHandler(handlers); + server.setDefaultHandler(new DefaultHandler()); + server.setHandler(contexts); // Next the behavior as defined by etc/jetty-requestlog.xml // the id="RequestLog" @@ -359,14 +351,14 @@ public class ServletRequestLogTest } /** - * Test a RequestLogHandler at the end of a HandlerCollection. - * and also with the default ErrorHandler as server bean in place. + * Test a RequestLogHandler + * also with the default ErrorHandler as server bean in place. * * @throws Exception on test failure */ @ParameterizedTest @MethodSource("data") - public void testLogHandlerCollectionErrorHandlerServerBean(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception + public void testLogHandlerErrorHandlerServerBean(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception { Server server = new Server(); ServerConnector connector = new ServerConnector(server); @@ -376,11 +368,10 @@ public class ServletRequestLogTest ErrorHandler errorHandler = new ErrorHandler(); server.addBean(errorHandler); + // First the behavior as defined in etc/jetty.xml ContextHandlerCollection contexts = new ContextHandlerCollection(); - DefaultHandler defaultHandler = new DefaultHandler(); - Handler.Collection handlers = new Handler.Collection(); - handlers.setHandlers(contexts, defaultHandler); - server.setHandler(handlers); + server.setDefaultHandler(new DefaultHandler()); + server.setHandler(contexts); // Next the behavior as defined by etc/jetty-requestlog.xml // the id="RequestLog" @@ -438,24 +429,24 @@ public class ServletRequestLogTest } /** - * Test a RequestLogHandler at the end of a HandlerCollection + * Test a RequestLog * using servlet specific error page mapping. * * @throws Exception on test failure */ @ParameterizedTest @MethodSource("data") - public void testLogHandlerCollectionSimpleErrorPageMapping(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception + public void testLogHandlerSimpleErrorPageMapping(Servlet testServlet, String requestPath, String expectedLogEntry) throws Exception { Server server = new Server(); ServerConnector connector = new ServerConnector(server); connector.setPort(0); server.setConnectors(new Connector[]{connector}); + // First the behavior as defined in etc/jetty.xml ContextHandlerCollection contexts = new ContextHandlerCollection(); - Handler.Collection handlers = new Handler.Collection(); - handlers.setHandlers(contexts, new DefaultHandler()); - server.setHandler(handlers); + server.setDefaultHandler(new DefaultHandler()); + server.setHandler(contexts); // Next the behavior as defined by etc/jetty-requestlog.xml // the id="RequestLog" @@ -532,14 +523,10 @@ public class ServletRequestLogTest connector.setPort(0); server.setConnectors(new Connector[]{connector}); - // First the behavior as defined in etc/jetty.xml (as is) - // id="Contexts" + // First the behavior as defined in etc/jetty.xml ContextHandlerCollection contexts = new ContextHandlerCollection(); - // id="DefaultHandler" - DefaultHandler defaultHandler = new DefaultHandler(); - Handler.Collection handlers = new Handler.Collection(); - handlers.setHandlers(contexts, defaultHandler); - server.setHandler(handlers); + server.setDefaultHandler(new DefaultHandler()); + server.setHandler(contexts); // Next the proposed behavioral change to etc/jetty-requestlog.xml // the id="RequestLog" diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DeploymentErrorTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DeploymentErrorTest.java index 1f1df53a3e3..64c55b2a107 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DeploymentErrorTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DeploymentErrorTest.java @@ -46,7 +46,6 @@ 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.HandlerList; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; @@ -107,7 +106,7 @@ public class DeploymentErrorTest server.addBean(deploymentManager); // Server handlers - server.setHandler(new HandlerList(contexts, new DefaultHandler())); + server.setHandler(contexts); // Setup Configurations Configurations.setServerDefault(server) diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DigestPostTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DigestPostTest.java index 1f3491732e6..8c5e8ae6ffa 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DigestPostTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/DigestPostTest.java @@ -50,7 +50,6 @@ 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.HandlerList; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.NanoTime; import org.eclipse.jetty.util.TypeUtil; @@ -142,7 +141,7 @@ public class DigestPostTest security.setConstraintMappings(Collections.singletonList(mapping)); - _server.setHandler(new HandlerList(context, new DefaultHandler())); + _server.setHandler(context); _server.start(); } diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/FailedSelectorTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/FailedSelectorTest.java index 228cc28acaf..25c0512c129 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/FailedSelectorTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/java/org/eclipse/jetty/ee9/test/FailedSelectorTest.java @@ -49,7 +49,6 @@ import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.eclipse.jetty.util.thread.Scheduler; @@ -112,7 +111,7 @@ public class FailedSelectorTest ServletHolder closeHolder = new ServletHolder(new CloseSelectorServlet(connector)); context.addServlet(closeHolder, "/selector/close"); - server.setHandler(new HandlerList(context, new DefaultHandler())); + server.setHandler(context); server.start(); } diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml index 845c385fc46..22e6afcc734 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/DefaultHandler.xml @@ -20,25 +20,18 @@ - - - - - - - - - /tests - /default - - - - - default - - - - + + + + /tests + /default + + + + + default + + diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml index ce5c6475a3b..5ebed9f8b53 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/RFC2616Base.xml @@ -9,70 +9,66 @@ - - - https - - 32768 - 8192 - 8192 - true - false - 1024 + + https + + 32768 + 8192 + 8192 + true + false + 1024 - + + + + + + + + + + + + + /tests + + + VirtualHost + + + /virtualhost + + virtual + + + + + /tests + /default + + default + + + + + /echo + + echo + + + + + - - - - - - - - - - - - - /tests - - - VirtualHost - - - /virtualhost - - virtual - - - - - /tests - /default - - default - - - - - /echo - - echo - - - - - - - - + diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/basic-server.xml b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/basic-server.xml index 74283e41641..25f402405a0 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/basic-server.xml +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-integration/src/test/resources/basic-server.xml @@ -19,18 +19,7 @@ - - - - - - - - - - - - + diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-loginservice/src/test/java/org/eclipse/jetty/ee9/loginservice/DatabaseLoginServiceTestServer.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-loginservice/src/test/java/org/eclipse/jetty/ee9/loginservice/DatabaseLoginServiceTestServer.java index 42f004b5c90..ace14868333 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-loginservice/src/test/java/org/eclipse/jetty/ee9/loginservice/DatabaseLoginServiceTestServer.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-loginservice/src/test/java/org/eclipse/jetty/ee9/loginservice/DatabaseLoginServiceTestServer.java @@ -37,7 +37,6 @@ import org.eclipse.jetty.ee9.servlet.ServletContextHandler; import org.eclipse.jetty.ee9.servlet.ServletHolder; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.toolchain.test.FS; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.security.Constraint; diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/CoreServer.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/CoreServer.java index ee969bef5b9..9607dcfb423 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/CoreServer.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/main/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/CoreServer.java @@ -20,8 +20,6 @@ import org.eclipse.jetty.ee9.websocket.jakarta.tests.framehandlers.FrameEcho; import org.eclipse.jetty.ee9.websocket.jakarta.tests.framehandlers.WholeMessageEcho; 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.HandlerList; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -61,7 +59,7 @@ public class CoreServer extends ContainerLifeCycle // Add Handler WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(); upgradeHandler.addMapping("/*", negotiator); - server.setHandler(new HandlerList(upgradeHandler, new DefaultHandler())); + server.setHandler(upgradeHandler); // Start Server addBean(server); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/RestartContextTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/RestartContextTest.java index 2fbf325190e..5e9405f1bef 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/RestartContextTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jakarta-tests/src/test/java/org/eclipse/jetty/ee9/websocket/jakarta/tests/RestartContextTest.java @@ -32,8 +32,6 @@ import org.eclipse.jetty.ee9.websocket.jakarta.server.config.JakartaWebSocketSer import org.eclipse.jetty.ee9.websocket.jakarta.server.internal.JakartaWebSocketServerContainer; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; @@ -67,7 +65,7 @@ public class RestartContextTest context.addEventListener(new AddEndpointListener()); // Setup handler tree - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); // Start server server.start(); @@ -103,11 +101,8 @@ public class RestartContextTest serverContainer.addEndpoint(EchoEndpoint.class); }); - // Setup handler tree - HandlerList handlers = new HandlerList(context.getCoreContextHandler(), new DefaultHandler()); - - // Add handler tree to server - server.setHandler(handlers); + // Add context to server + server.setHandler(context); // Start server server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee9/websocket/server/browser/BrowserDebugTool.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee9/websocket/server/browser/BrowserDebugTool.java index 8aa7f319ce1..6b03d9f8990 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee9/websocket/server/browser/BrowserDebugTool.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-server/src/test/java/org/eclipse/jetty/ee9/websocket/server/browser/BrowserDebugTool.java @@ -34,8 +34,6 @@ import org.eclipse.jetty.ee9.websocket.server.JettyWebSocketServletFactory; import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContainerInitializer; 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.HandlerList; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.ResourceFactory; @@ -109,7 +107,7 @@ public class BrowserDebugTool ServletHolder defHolder = new ServletHolder("default", DefaultServlet.class); context.addServlet(defHolder, "/"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); LOG.info("{} setup on port {}", this.getClass().getName(), port); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/BadNetworkTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/BadNetworkTest.java index e9cf6d2ffe7..1253c5066b1 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/BadNetworkTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/BadNetworkTest.java @@ -32,8 +32,6 @@ import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContai import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -81,7 +79,7 @@ public class BadNetworkTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientCloseTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientCloseTest.java index 2752c4dc357..6f8b05db532 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientCloseTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientCloseTest.java @@ -41,8 +41,6 @@ import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.EofException; 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.HandlerList; import org.eclipse.jetty.util.BlockingArrayQueue; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.OpCode; @@ -131,7 +129,7 @@ public class ClientCloseTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientSessionsTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientSessionsTest.java index c6b97c43ac1..881e8ce0f8e 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientSessionsTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/ClientSessionsTest.java @@ -36,8 +36,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.ee9.websocket.tests.EchoCreator; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -74,7 +72,7 @@ public class ClientSessionsTest }); context.addServlet(holder, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/SlowClientTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/SlowClientTest.java index 10f2044f820..d911ef7edd6 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/SlowClientTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/client/SlowClientTest.java @@ -30,8 +30,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.ee9.websocket.tests.EchoSocket; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,7 +74,7 @@ public class SlowClientTest }); context.addServlet(websocket, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameAnnotationTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameAnnotationTest.java index d6bdc8f45d9..12b2ef011c9 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameAnnotationTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameAnnotationTest.java @@ -43,8 +43,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.AfterEach; @@ -85,7 +83,7 @@ public class FrameAnnotationTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); server.start(); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameListenerTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameListenerTest.java index 0e0f076f533..5c9eafb39f0 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameListenerTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/FrameListenerTest.java @@ -36,8 +36,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.OpCode; import org.junit.jupiter.api.AfterEach; @@ -78,7 +76,7 @@ public class FrameListenerTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); server.start(); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/PartialListenerTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/PartialListenerTest.java index 8c88ca6a079..5363826aa91 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/PartialListenerTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/PartialListenerTest.java @@ -39,8 +39,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import org.junit.jupiter.api.AfterEach; @@ -81,7 +79,7 @@ public class PartialListenerTest context.addServlet(closeEndpoint, "/ws"); JettyWebSocketServletContainerInitializer.configure(context, null); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); server.start(); } diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/ServerCloseTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/ServerCloseTest.java index 53bebd91ad1..13eab55ce89 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/ServerCloseTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/ServerCloseTest.java @@ -33,8 +33,6 @@ import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; import org.eclipse.jetty.logging.StacklessLogging; 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.HandlerList; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -80,7 +78,7 @@ public class ServerCloseTest }); context.addServlet(closeEndpoint, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start(); diff --git a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/SlowServerTest.java b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/SlowServerTest.java index 9b1e4bf6719..a156a7b9cd5 100644 --- a/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/SlowServerTest.java +++ b/jetty-ee9/jetty-ee9-websocket/jetty-ee9-websocket-jetty-tests/src/test/java/org/eclipse/jetty/ee9/websocket/tests/server/SlowServerTest.java @@ -29,8 +29,6 @@ import org.eclipse.jetty.ee9.websocket.server.config.JettyWebSocketServletContai import org.eclipse.jetty.ee9.websocket.tests.CloseTrackingEndpoint; 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.HandlerList; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -76,7 +74,7 @@ public class SlowServerTest }); context.addServlet(websocket, "/ws"); - server.setHandler(new HandlerList(context.getCoreContextHandler(), new DefaultHandler())); + server.setHandler(context.getCoreContextHandler()); JettyWebSocketServletContainerInitializer.configure(context, null); server.start();