-
Couldn't load subscription status.
- Fork 2k
Description
Jetty version(s)
12.1.0.alpha1
Jetty Environment
ee10
Java version/vendor (use: java -version)
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)
Description
I have migrated an application from:
Dropwizard 4.0.10
Jetty 11.0.24
to:
Dropwizard 5.0.0-alpha.5
Jetty 12.1.0.alpha1
In the Jetty 12 version of the application, the error attributes are not getting set on the request, which results in the ErrorPageErrorHandler returning a generic error page rather than my custom error page.
How to reproduce?
I have a Jetty 11 and Jetty 12 version of the application here:
https://github.com/rorytorneymf/jetty11-error-attributes/blob/main/src/main/java/com/example/app/App.java
https://github.com/rorytorneymf/jetty12-error-attributes/blob/main/src/main/java/com/example/app/App.java
To debug, debug the main method with the arguments server app-config-dev.json.
If you debug the Jetty 11 version, setting a breakpoint on the AttributesMap.setAttribute and the ErrorPageErrorHandler.getErrorPage method, then navigate to an invalid URL such as http://localhost:3200/bla you will see that the error attributes are getting set via the HttpChannelState.sendError method:
which then results in this line of code in the ErrorPageErrorHandler returning an appropriate value (403 in this case), which gets mapped to the custom error page:
errorStatusCode = (Integer)request.getAttribute(Dispatcher.ERROR_STATUS_CODE);However, repeating the above steps in the Jetty 12 version of the app, you will see that the error attributes are not getting set, which then results in this line of code in the ErrorPageErrorHandler returning null, which results in a generic error page being shown rather than my custom error page:
errorStatusCode = (Integer)request.getAttribute(org.eclipse.jetty.server.handler.ErrorHandler.ERROR_STATUS);From what I can tell, the error attributes should be getting set via ServletChannelState.sendError in Jetty 12, but that is not getting called.
Note:
I originally thought that this was the same issue as #12505, but I don't think that's the case, as there does not seem to be any error attributes getting set (either server or servlet attributes).