-
Notifications
You must be signed in to change notification settings - Fork 2k
fixes for Response.writeError with servlet error dispatch #12698
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
fixes for Response.writeError with servlet error dispatch #12698
Conversation
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
|
@lachlan-roberts this is quite a hefty refactor of |
|
@janbartel I have aligned the EE10 ErrorHandler with changes from the EE11 one. I think maybe the changes can be reduced, but I wanted the EE10 If we really don't want to change the EE10 |
jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AuthenticationState.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ErrorHandler.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
|
@gregw @janbartel ready for review |
gregw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few documentation changes
I also restarted CI, to get a clean build
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
Outdated
Show resolved
Hide resolved
jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet/ErrorHandler.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
|
Hmm AsyncMiddleMan tests failing here as well. So probably unrelated. |
gregw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor niggle
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
Show resolved
Hide resolved
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
…iteErrorBeforeServlet
jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/AuthenticationState.java
Show resolved
Hide resolved
| value += ", charset=\"" + charset.name() + "\""; | ||
| res.getHeaders().put(HttpHeader.WWW_AUTHENTICATE.asString(), value); | ||
|
|
||
| // Don't use AuthenticationState.writeError, to avoid possibility of doing a Servlet error dispatch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a known specific set of cases/codes for which we want to avoid doing a Servlet error dispatch? If so, can we codify in AuthenticationState.writeError and just always call it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its just based on the use case rather than the code. I don't see why 401 couldn't be dispatched to a servlet error handler in a different case.
Although we only ever use AuthenticationState.writeError with 403 status codes.
Signed-off-by: Lachlan Roberts <lachlan.p.roberts@gmail.com>
…iteErrorBeforeServlet
…iteErrorBeforeServlet
See issue #12697
Doing a
Response.writeError()will try to invoke the servlet ErrorHandler, which can do an ERROR dispatch. This does not work properly if it is not done from within the scope of theServletChannel.ErrorHandlerimplementations to stop dispatching to error pages unless we have already started theServletChannel.Authenticators now use theServletChannelmechanism to do asendError()when theServletChannelstarts handling the request. It uses a new static methodErrorHandler.writeErrorwhich is overriden by the servletErrorHandlers.