Version: 2.3.x

i build a spring boot project, i need to response error message in a RESTful API, so i do that:

-pom-

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.0.RELEASE</version>
</parent>

 <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
  </dependencies>

-Java Code-

  @RequestMapping(value = "/bad-token", method = RequestMethod.GET)
    public void bad(HttpServletResponse response) throws IOException {
        response.sendError(401, "this is bad token");
        return;
    }

and i find the ‘message’ in the api result info is blank,like that

-2.3.0-

{
    "timestamp": "2020-11-05T09:44:45.497+0000",
    "status": 401,
    "error": "Unauthorized",
    "message": "",
    "path": "/bad"
}

this problem has not occurred in previous versions , i switched to 2.2.10.RELEASE and i got the 'message'

-2.2.10-

{
    "timestamp": "2020-11-05T09:44:45.497+0000",
    "status": 401,
    "error": "Unauthorized",
    "message": "this is bad token",
    "path": "/bad"
}

I tested and found this problem in any version greater than 2.3.0.RELEASE. I'm not sure it is a bug

Comment From: ztomic

This is the expected default behaviour in Spring Boot 2.3. Please see the relevant section of the release notes for details.

Originally posted by @wilkinsona in https://github.com/spring-projects/spring-boot/issues/22049#issuecomment-647434391

Comment From: snicoll

Thanks @ztomic!

@haochihchieh please review the section of the release notes that's linked above.