Affects: 5.2.3.RELEASE
I have an application which uses both spring webflux and spring web mvc because of certain constraints.
when i try to add an endpoint which receives a reactive type (Publisher) in @RequestBody i get an error.
endpoint example:
@PostMapping(consumes = MediaType.APPLICATION_STREAM_JSON_VALUE)
public Mono<Void> doSomething(@RequestBody Publisher<Entity> entities){
//...
}
i got this error when called the endpoint:
org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class org.reactivestreams.Publisher]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of org.reactivestreams.Publisher (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
when i tried it in an application that uses spring webflux only, it worked well. spring web mvc does support sending a reactive type in the response, is there any limitation that prevents the support of receiving a reactive type in request body? is it something that is planned to be supported in the future?
Comment From: rstoyanchev
You can see the list of supported arguments in the docs including "Reactive types are not supported for any arguments".
Request handling and response writing can be separated with an async boundary through the support for asynchronous requests in the Servlet API, i.e. request.startAsync(). The same cannot be done for input. The difference is that when going from Objects to I/O we can keep using blocking I/O to write individual Objects. The only way to support asynchronous reading is to switch to non-blocking I/O and that cannot be done without deeper changes as was done in WebFlux.