@ResponseStatus documentation incorrect #30305
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: documentation
A documentation task
Milestone
I think the documentation of
@ResponseStatus
in spring-web 6.0.7 is not correct. It says:"The status code is applied to the HTTP response when the handlermethod is invoked and overrides status information set by other means,like ResponseEntity or "redirect:"."
However, when the following method is called in a
@Controller
class it does not return theHttpStatus.I_AM_A_TEAPOT
status (418) but theHttpStatus.INTERNAL_SERVER_ERROR
(500):So, effectively the status set on the ResponseEntity is returned which is the opposite of what the documentation says.
When debugging, at some point the following method is called:
Here, the ServletServerHttpResponse outputMessage initially contains the code 418 but later this is overwritten by the status of the ResponseEntity. It appears a ResponseEntity is also created within the method if the return value of the controller method is a ProblemDetail or ErrorResponse which could mean that a status on these types also overwrites the status defined by the
@ResponseStatus
.The following controller method returns the expected status code 418:
My POM.xml looks as follows:
My main class:
And my controller class:
The text was updated successfully, but these errors were encountered: