-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
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:
- webflux-responsestatus.zip (55.52 kB)
Issue Links:
- Using @ControllerAdvice with WebFlux [SPR-16554] #21097 Using
@ControllerAdvice
with WebFlux