Affected component: spring-webflux Version: 2.2.4.RELEASE

When returning a custom exception with a @ResponseStatus annotation in a controller method, spring mvc extracts the message of the exception into the error attribute message. This message will then be available in the default json response and can also be used in templates.

Spring webflux however ignores the message of the exception when it's annotated with @ResponseStatus. The only way to set a message then is via the reason parameter of the annotation.

I created a sample application with a (currently failing) WebFluxTest to demonstrate the behaviour of ignoring the message.

After some investigation in the code, I think that in DefaultErrorAttributes, when the message is determined, it's not checked if the value for the reason parameter is an empty string, which is the default value for this parameter. Therefore this empty string is always preferred to the message of the message of the exception.

Comment From: snicoll

@xabgesagtx thanks for the report and the sample!

Comment From: wilkinsona

Closing in favour of #19901.