-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jetty 12.1.x tck error message #12011
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0a06a60
Fix for bad error message in tck test
janbartel d5865e6
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
janbartel 748dcf9
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
janbartel 25972ec
Add TODO and change param names
janbartel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -73,6 +73,14 @@ public boolean errorPageForMethod(String method) | |||||
}; | ||||||
} | ||||||
|
||||||
private static Object getRequestErrorAttribute(HttpServletRequest request, String servletApiName, String jettyName) | ||||||
{ | ||||||
Object o = request.getAttribute(servletApiName); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (o == null) | ||||||
o = request.getAttribute(jettyName); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return o; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean handle(Request request, Response response, Callback callback) throws Exception | ||||||
{ | ||||||
|
@@ -126,7 +134,7 @@ public boolean handle(Request request, Response response, Callback callback) thr | |||||
} | ||||||
} | ||||||
|
||||||
String message = (String)request.getAttribute(Dispatcher.ERROR_MESSAGE); | ||||||
String message = (String)getRequestErrorAttribute(httpServletRequest, Dispatcher.ERROR_MESSAGE, org.eclipse.jetty.server.handler.ErrorHandler.ERROR_MESSAGE); | ||||||
if (message == null) | ||||||
message = HttpStatus.getMessage(response.getStatus()); | ||||||
generateAcceptableResponse(servletContextRequest, httpServletRequest, httpServletResponse, response.getStatus(), message); | ||||||
|
@@ -416,7 +424,7 @@ protected void writeErrorPageMessage(HttpServletRequest request, Writer writer, | |||||
{ | ||||||
htmlRow(writer, "SERVLET", request.getAttribute(Dispatcher.ERROR_SERVLET_NAME)); | ||||||
} | ||||||
Throwable cause = (Throwable)request.getAttribute(Dispatcher.ERROR_EXCEPTION); | ||||||
Throwable cause = (Throwable)getRequestErrorAttribute(request, Dispatcher.ERROR_EXCEPTION, org.eclipse.jetty.server.handler.ErrorHandler.ERROR_EXCEPTION); | ||||||
while (cause != null) | ||||||
{ | ||||||
htmlRow(writer, "CAUSED BY", cause); | ||||||
|
@@ -451,7 +459,7 @@ protected void writeErrorPlain(HttpServletRequest request, PrintWriter writer, i | |||||
{ | ||||||
writer.printf("SERVLET: %s%n", request.getAttribute(Dispatcher.ERROR_SERVLET_NAME)); | ||||||
} | ||||||
Throwable cause = (Throwable)request.getAttribute(Dispatcher.ERROR_EXCEPTION); | ||||||
Throwable cause = (Throwable)getRequestErrorAttribute(request, Dispatcher.ERROR_EXCEPTION, org.eclipse.jetty.server.handler.ErrorHandler.ERROR_EXCEPTION); | ||||||
while (cause != null) | ||||||
{ | ||||||
writer.printf("CAUSED BY %s%n", cause); | ||||||
|
@@ -465,7 +473,7 @@ protected void writeErrorPlain(HttpServletRequest request, PrintWriter writer, i | |||||
|
||||||
protected void writeErrorJson(HttpServletRequest request, PrintWriter writer, int code, String message) | ||||||
{ | ||||||
Throwable cause = (Throwable)request.getAttribute(Dispatcher.ERROR_EXCEPTION); | ||||||
Throwable cause = (Throwable)getRequestErrorAttribute(request, Dispatcher.ERROR_EXCEPTION, org.eclipse.jetty.server.handler.ErrorHandler.ERROR_EXCEPTION); | ||||||
Object servlet = request.getAttribute(Dispatcher.ERROR_SERVLET_NAME); | ||||||
Map<String, String> json = new HashMap<>(); | ||||||
|
||||||
|
@@ -490,7 +498,7 @@ protected void writeErrorJson(HttpServletRequest request, PrintWriter writer, in | |||||
|
||||||
protected void writeErrorPageStacks(HttpServletRequest request, Writer writer) throws IOException | ||||||
{ | ||||||
Throwable th = (Throwable)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); | ||||||
Throwable th = (Throwable)getRequestErrorAttribute(request, RequestDispatcher.ERROR_EXCEPTION, org.eclipse.jetty.server.handler.ErrorHandler.ERROR_EXCEPTION); | ||||||
if (th != null) | ||||||
{ | ||||||
writer.write("<h3>Caused by:</h3><pre>"); | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why is this method necessary?
I thought the policy was that we would always set the jetty(core) attribute and then any request wrapper used for an error dispatch to a filter/servlet would intercept the servlet attributes and lookup the jetty ones
So our code should then only ever need to lookup jetty(core) attributes? Unless there is a case where an application sets them and we are expected to act on them?
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.
That is part of the refactoring effort, which is a much wider scope than just satisfying the tck.