Use jakarta.servlet.error.exception request attribute on jetty11 (#8503)

This commit is contained in:
Lauri Tulmin 2023-05-18 03:03:22 +03:00 committed by GitHub
parent 00f381802a
commit f00393260c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 2 deletions

View File

@ -57,6 +57,7 @@ public class JettyHelper<REQUEST, RESPONSE> extends ServletHelper<REQUEST, RESPO
}
private static String errorExceptionAttributeName() {
// this method is only used on jetty versions before 9.4
return "javax.servlet.error.exception";
}
}

View File

@ -43,7 +43,7 @@ abstract class JettyServlet5Test extends AbstractServlet5Test<Object, Object> {
ServletContextHandler servletContext = new ServletContextHandler(null, contextPath)
servletContext.errorHandler = new ErrorHandler() {
protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException {
Throwable th = (Throwable) request.getAttribute("javax.servlet.error.exception")
Throwable th = (Throwable) request.getAttribute("jakarta.servlet.error.exception")
writer.write(th ? th.message : message)
}
}

View File

@ -34,7 +34,7 @@ class JettyServletHandlerTest extends AbstractServlet5Test<Object, Object> {
setupServlets(handler)
server.addBean(new ErrorHandler() {
protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException {
Throwable th = (Throwable) request.getAttribute("javax.servlet.error.exception")
Throwable th = (Throwable) request.getAttribute("jakarta.servlet.error.exception")
writer.write(th ? th.message : message)
}
})