Skip to content

Support @ResponseStatus-annotated exceptions on WebFlux [SPR-16567] #21109

@spring-projects-issues

Description

@spring-projects-issues

Andreas Schilling opened SPR-16567 and commented

As of now using @ResponseStatus annotations on custom exceptions or exception handler methods of @ControllerAdvice classes is not supported.
This is a pitfall when coming from the classic web stack where this is kind of the idiomatic way to apply specific response codes to custom exceptions.

Either using ResponseStatusException directly or applying a wrapper (e.g. through a @ControllerAdvice) is a workaround but feels like it is something the framework should do.
As described in this comment this seems easily doable through the ResponseStatusExceptionHandler.

A small test setup is attached to this ticket. Running ./gradlew test currently fails as the response status for the custom exception is not set to 400 but by default to 500.


Affects: 5.0.4

Attachments:

Issue Links:

Referenced from: commits ba5ef64, b8d94f8

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions