-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify whether javax.servlet.error.exception_type and javax.servlet.error.exception refer to a wrapped or unwrapped ServletException #388
Comments
I think the TCK is checking that the original exception was thrown without wrapping.
Looking at the specification I don't see that made explicit anywhere. I think it should be. We can also make clear that |
@markt-asf my understanding of that TCK test is that the servlet throws the wrapped exception - ie it throws To my mind it is wrong to unwrap a ServletException, because it throws away application context of who did the throwing and only gives us the root cause, which may not be the servlet that was called. |
@markt-asf the errorpage tests are invoked via reflection from the HttpTCKServlet class. When the test throws the exception, the HttpTCKServlet catches it and wraps it in a ServletException: |
My concern is the consistency of the content of attributes related to the mechanism of unwrapped if it's ServletException.
with as the TCK does As per specification the request is redirected to
I guess we need at least consistency (I would say attribute |
@janbartel Tx for the pointer. I'll take a closer look. |
I've been digging through the history and I think the current behaviour on unwrapping is as intended. The following change was made in Tomcat 4 back when it was the reference implementation: https://svn.apache.org/viewvc?view=revision&revision=301155 There is also the following text in the current servlet specification:
My reading of this is that it is expected that the error page might provide details specific to an exception type and therefore if the unwrapped exception is used to determine the error page, it is the unwrapped exception that needs to be set in the request attributes. I can image this being done for exceptions like That the TCK is testing this is a further indication that this is the intended behaviour. I confess I was initially surprised by this behaviour. It was only when I dug into the history did it start to make sense. Whether we agree the current behaviour is correct or needs to change, I think we need to clarify 10.9.1 and make it explicit that exceptions throws by Servlets should be optionally wrapped using the same rules as set out in 9.5. @olamy In Tomcat, at least, |
From section 10.9.2 Error Pages:
This section does not make clear when a ServletException is thrown that contains a wrapped exception, if the values of the request attributes
javax.servlet.error.exception_type
andjavax.servlet.error.exception
should be the unwrapped exception or not.Setting them to the unwrapped exception will remove stacktrace information that may be valuable.
On the other hand, the current servlet-tck seems to test that the values are unwrapped - see https://github.com/eclipse-ee4j/jakartaee-tck/blob/master/src/com/sun/ts/tests/servlet/spec/errorpage/URLClient.java#L76
The text was updated successfully, but these errors were encountered: