Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom web input exceptions in WebFlux [SPR-17232] #21765

spring-issuemaster opened this Issue Aug 31, 2018 · 2 comments


None yet
2 participants
Copy link

spring-issuemaster commented Aug 31, 2018

Enzo Bonggio opened SPR-17232 and commented

  1. Having a PostMapping like this
@PostMapping("/body") public Mono<Void> body(@Valid @RequestBody BodyClass bodyClass) { return Mono.empty().then(); }


  1. When we send a request with a null body
private TestRestTemplate restTemplate 
def "test post body null"() {
    def bodyClass = null
    def headers = new HttpHeaders()
    def request = new HttpEntity<MultiValueMap<String, String>>(bodyClass, headers);
    def response = restTemplate.postForEntity("/body", request, ErrorResponse.class)
    assert response.statusCode == HttpStatus.BAD_REQUEST


  1. We need to handle ServerWebInputException that is thrown from AbstractMessageReaderArgumentResolver 
private ServerWebInputException handleMissingBody(MethodParameter param) {
     return new ServerWebInputException("Request body is missing: " + param.getExecutable().toGenericString());


Right now there is no way to override method that is thrown from AbstractMessageReaderArgumentResolver 

At least we should send MethodParameter in the constructor of ServerWebInputException or tell a way to override that implementation   

Affects: 5.0.8


This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Aug 31, 2018

Enzo Bonggio commented

I have another case where this happen:


When you are missing a header we have the same issue on RequestHeaderMethodArgumentResolver

protected void handleMissingValue(String name, MethodParameter parameter) {
 String type = parameter.getNestedParameterType().getSimpleName();
 throw new ServerWebInputException("Missing request header '" + name +
 "' for method parameter of type " + type);

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 21, 2018

Rossen Stoyanchev commented

Yes, indeed we should be using the constructor with a MethodParameter in places where it is available. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.