Hello everybody, I have a problem with the following code:

@RestController
public class DemoController {
    @ExceptionHandler(IllegalArgumentException.class)
    @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "no reason at all")
    public void illegalArgumentException() {
    }

    @GetMapping(value="try/{option}")
    public ResponseEntity<String> tryOption(@PathVariable String option){
        if(!"ok".equals(option))
            throw new IllegalArgumentException();
        return ResponseEntity.ok("Everything is ok!");
    }
}

Using spring boot 2.2.7.RELEASE works as expected when requesting: http://localhost:8080/try/nok The result is a status = 400 and reason = "no reason at all".

However, if I update the version to spring boot 2.3.0.RELEASE + (tried with 2.3.1.RELEASE also), the same example returns status=400 and no reason.

thanks in advance. regards,

Comment From: grkn

In org.springframework.boot.web.servlet.error.DefaultErrorAttributes#getErrorAttributes(), There is if case below

if (!options.isIncluded(Include.MESSAGE) && errorAttributes.get("message") != null) {
            errorAttributes.put("message", "");
}

code block sets the message to empty because of new property.

server.error.include-message=always or on-param or never. I guess this is not bug. We have to specify property as mentioned above but ResponseStatus's reason attribute may have a special implementation. Default message behavior of javax.servlet.error.message is used to get error message from request.

Comment From: bclozel

Indeed, this is an expected change underlined in the release notes.

Thanks!