Error handling no longer works for JSON controller method returning Flux under 6.0.0-M5 #29038
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: regression
A bug that is also a regression
Milestone
Affects: spring-webflux:6.0.0-M5
What I am trying to achieve
I am using Java 17 and
spring-webflux:6.0.0-M5
, pulled byspring-boot-starter-parent:3.0.0-M4
, to build a JSON web API.One of my controllers returns a
Flux<SomeObject>
, and when a domain error occurs I trigger an error using something likeFlux.error(new ResponseStatusException(HttpStatus.I_AM_A_TEAPOT))
.Expected behaviour
With
spring-webflux:6.0.0-M4
and below, when such an error occurs, it is caught by the framework and converted to a web Response like below:Even under
spring-webflux:6.0.0-M5
, this mechanism still works for controllers returning aMono<SomeObject>
or aFlux<String>
for example, onlyFlux<SomeObject>
is no longer working.Current behaviour
On controllers returning
Flux<SomeObject>
, the error signal does not seem to be caught anymore. When calling the app with curl it returns a generic 500 error, and when running JUnit tests an error as below occurs:To me, this looks like the error signal was not caught by the framework and passed down to the WebTestClient rather than converted to a web Response.
Code to replicate
I have set up a sample project on GitHub to replicate the issue, with 2 endpoints which show the expected behaviour and one which shows the erroneous one:
https://github.com/nico-incubiq/webflux-error-replicate/blob/main/src/test/java/com/test/ApplicationTest.java#L19-L35
The text was updated successfully, but these errors were encountered: