After upgrading from spring boot 2.2.8 to 2.3.1 we had failing tests.
If we throw a ResponseStatusException in a RestController in the corresponding test (using WebTestClient) the body is empty (no content).
However if we test it using curl/postman etc. the body is not empty and contains the desired error message in the json field "message".
git clone https://github.com/WtfJoke/springwebtestclientbug.git)SampleControllerTest 鈻讹笍 馃敶 SampleControllerTest 鈻讹笍 鉁旓笍 The demo projects also contains a branch with the same code with spring boot 2.2.8 where the same tests passes (see CI).

This is the expected default behaviour in Spring Boot 2.3. Please see the relevant section of the release notes for details.
@wilkinsona Thank you for your answer and linking me to the corresponding section of the release notes. 馃憤
What I dont get, is why is the behaviour different from WebTestClient and a regular http client like curl (where the error body is delivered, even if server.error.include-message is not defined)?
E.g why is the body included in curl and not in webtestclient?
Sorry, I missed that part of the problem. We'll need to take a closer look.
The body is not empty when using WebTestClient. If I modify you test to the following:
@Test
fun exception() {
webTestClient.get().uri("/exception")
.exchange()
.expectStatus().isBadRequest
.expectBody()
.isEmpty()
}
It fails with the following output:
Expected empty body
> GET http://localhost:59273/exception
> WebTestClient-Request-Id: [1]
No content
< 400 BAD_REQUEST Bad Request
< Content-Type: [application/json]
< Transfer-Encoding: [chunked]
< Date: [Mon, 22 Jun 2020 12:41:20 GMT]
< Connection: [close]
{"timestamp":"2020-06-22T12:41:20.124+00:00","status":400,"error":"Bad Request","message":"","path":"/exception"}
java.lang.AssertionError: Expected empty body
As expected, the body is not empty but message is empty. If I then reinstate your original test and add server.error.include-message=always to application.properties, the test passes.
Thanks for your analysis, I mistakenly took No content for empty body. Sorry about that.
I already tested server.error.include-mesage=always before and it works as expected 馃憤
Ah, I see. In the output above, No content is for the body of the request.
Most helpful comment
Sorry, I missed that part of the problem. We'll need to take a closer look.