Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 5.1.2
-
Fix Version/s: None
-
Labels:
-
Last commented by a User:true
Description
In a Spring Boot application with reactive web I have a POST endpoint with a request body of type Mono. This works fine with Spring Boot 2.0.6 (Spring 5.0.10). But when I upgraded to Spring Boot 2.1.0 (Spring 5.1.2) the application throws an error "Request body is missing"
To reproduce the problem create a Spring Boot 2.1.0 application with Spring Initializr and add "Reactive Web" as sole dependency.
Then add a PostMapping method to the main class
@SpringBootApplication @RestController public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } @PostMapping("/register") public void register(@RequestBody Mono<String> token) { token.subscribe(System.out::println); } }
When you call this endpoint with curl the application throws an error
curl -v -d "token" -H "Content-Type: text/plain" http://localhost:8080/register
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST "Request body is missing: public void com.example.demo.DemoApplication.register(reactor.core.publisher.Mono<java.lang.String>)" Caused by: org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST "Request body is missing: public void com.example.demo.DemoApplication.register(reactor.core.publisher.Mono<java.lang.String>)" at org.springframework.web.reactive.result.method.annotation.AbstractMessageReaderArgumentResolver.handleMissingBody(AbstractMessageReaderArgumentResolver.java:223) ~[spring-webflux-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.web.reactive.result.method.annotation.AbstractMessageReaderArgumentResolver.lambda$readBody$5(AbstractMessageReaderArgumentResolver.java:188) ~[spring-webflux-5.1.2.RELEASE.jar:5.1.2.RELEASE]
When you change the Spring Boot dependency to 2.0.6.RELEASE and run the same curl command you see that it works without any problems.