-
Notifications
You must be signed in to change notification settings - Fork 191
fix: Fall back to InternalServerError when error view rendering fails #23177
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
base: main
Are you sure you want to change the base?
Conversation
Prevents navigation corruption when error view's parent layout throws an exception during afterNavigation by catching the exception and rendering InternalServerError as fallback. Fixes #22146
|
| @Override | ||
| public void afterNavigation(AfterNavigationEvent event) { | ||
| events.add(event); | ||
| if (event.getLocation().getPath().equals("error")) { |
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.
| if (event.getLocation().getPath().equals("error")) { | |
| if (true) { |
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.
doesn't need the if at all. Can just throw the exception.
| // Error view threw an exception - fall back to | ||
| // InternalServerError | ||
| LoggerFactory.getLogger(Router.class).error( | ||
| "Exception occurred while rendering error view for '{}'. " | ||
| + "Falling back to InternalServerError.", | ||
| location.getPath(), errorHandlingException); |
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.
The original exception should also be logged as now it will disappear and only the exception failing the exception view rendering is logged.



Prevents navigation corruption when error view's parent layout throws an exception during afterNavigation by catching the exception and rendering InternalServerError as fallback.
Fixes #22146