|
1 | 1 | /* |
2 | | - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2020 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
35 | 35 | import org.eclipse.jetty.server.handler.ErrorHandler; |
36 | 36 | import org.eclipse.jetty.server.handler.HandlerCollection; |
37 | 37 | import org.eclipse.jetty.server.handler.HandlerWrapper; |
| 38 | +import org.eclipse.jetty.servlet.ErrorPageErrorHandler; |
38 | 39 | import org.eclipse.jetty.util.thread.QueuedThreadPool; |
39 | 40 | import org.eclipse.jetty.util.thread.ThreadPool; |
| 41 | +import org.eclipse.jetty.webapp.AbstractConfiguration; |
40 | 42 | import org.eclipse.jetty.webapp.Configuration; |
41 | 43 | import org.eclipse.jetty.webapp.WebAppContext; |
42 | 44 | import org.junit.jupiter.api.Test; |
@@ -301,4 +303,24 @@ public void contextDestroyed(ServletContextEvent event) { |
301 | 303 | }); |
302 | 304 | } |
303 | 305 |
|
| 306 | + @Test |
| 307 | + void errorHandlerCanBeOverridden() { |
| 308 | + JettyServletWebServerFactory factory = getFactory(); |
| 309 | + factory.addConfigurations(new AbstractConfiguration() { |
| 310 | + |
| 311 | + @Override |
| 312 | + public void configure(WebAppContext context) throws Exception { |
| 313 | + context.setErrorHandler(new CustomErrorHandler()); |
| 314 | + } |
| 315 | + |
| 316 | + }); |
| 317 | + JettyWebServer jettyWebServer = (JettyWebServer) factory.getWebServer(); |
| 318 | + WebAppContext context = (WebAppContext) jettyWebServer.getServer().getHandler(); |
| 319 | + assertThat(context.getErrorHandler()).isInstanceOf(CustomErrorHandler.class); |
| 320 | + } |
| 321 | + |
| 322 | + private static class CustomErrorHandler extends ErrorPageErrorHandler { |
| 323 | + |
| 324 | + } |
| 325 | + |
304 | 326 | } |
0 commit comments