Skip to content
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

Fix return value of HandlerMethod is ignored if reason of @ResponseStatus present #31113

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Aug 25, 2023

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 25, 2023
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression labels Aug 25, 2023
@quaff quaff marked this pull request as draft August 25, 2023 09:23
@quaff
Copy link
Contributor Author

quaff commented Aug 25, 2023

It breaks tests introduced by d52fc3b, I'm not sure it's a bug should be fixed, maybe we should update the javadoc of ResponseStatus to clarify current behavior instead of fixing this.

@quaff
Copy link
Contributor Author

quaff commented Aug 28, 2023

Superseded by #31121

@quaff quaff closed this Aug 28, 2023
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 28, 2023
@bclozel bclozel removed the request for review from rstoyanchev August 28, 2023 07:09
bclozel pushed a commit that referenced this pull request Sep 7, 2023
When a handler method is annotated with `@ResponseStatus(reason="...")`,
Spring MVC will use `HttpServletResponse#sendError` to complete the
response. As a result, the Servlet container will send an HTML error
page and any existing data in the response buffer will be cleared.

This commit clarifies the `@ResponseStatus` Javadoc and ensures that a
message is logged at the WARN level if a handler method is annotated
like this and still returns a non-Void value. In this case, the return
value will be ignored and developers should be aware of this fact.

See gh-31113
Closes gh-31121
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) status: declined A suggestion or change that we don't feel we should currently apply type: regression A bug that is also a regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants