Skip to content

DefaultHandlerExceptionResolver::doResolveException no longer returns ModelAndView customized via protected method #29971

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

Closed
ryber opened this issue Feb 14, 2023 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@ryber
Copy link

ryber commented Feb 14, 2023

Impacted Version: spring-webmvc-6.0.4

Previously

DefaultHandlerExceptionResolver::doResolveException(HttpServletRequest request, HttpServletResponse response, @Nullable Object handler, Exception ex)

would return the ModelAndView when it was resolved from one of the specific methods (like handleHttpRequestMethodNotSupported)

Starting with 6, this method now sets a local variable of the ModelAndView and then does NOT return it. It ALWAYS returns null. in these cases.

see https://github.com/spring-projects/spring-framework/blob/main/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java#L167-L248

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 14, 2023
ryber referenced this issue Feb 14, 2023
DefaultHandlerExceptionResolver now supports ErrorResponse exceptions
and can map them to HTTP status and headers of the response. This
includes not only exceptions from spring-web,  but also any other
exception that implements ErrorResponse.

ResponseEntityExceptionHandler is updated along the same lines, now
also handling any ErrorResponseException. It can be used it for
RFC 7807 support for Spring MVC's own exceptions.

See gh-27052
@rstoyanchev rstoyanchev self-assigned this Feb 14, 2023
@rstoyanchev rstoyanchev added this to the 6.0.5 milestone Feb 14, 2023
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 14, 2023
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Feb 14, 2023

I presume the case is when you override a protected method to handle an exception, and return a ModelAndView rather than calling response#sendError, then the resulting ModelAndView is being ignored?

@ryber
Copy link
Author

ryber commented Feb 14, 2023

yes, well, specifically I'm getting a NullPointerException because I am expecting it to be returned

@ryber
Copy link
Author

ryber commented Feb 14, 2023

for now I have copied in the method from Spring 5 as a workaround

@rstoyanchev rstoyanchev changed the title DefaultHandlerExceptionResolver::doResolveException no longer returns resolved ModelAndView DefaultHandlerExceptionResolver::doResolveException no longer returns ModelAndView customized via protected method Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants