I have observed that on migrating from spring-boot 3.3.x to 3.4.0, the contentType
header in the response is set to null
if the response is empty
.
I am not able to find when this change was made and related to which pull request.
Ex :
@Test
fun `should work`() {
webTestClient.post()
.uri("/test")
.header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
.bodyValue("""{"gender": "MALE"}""")
.exchange()
.expectStatus().isOk
.expectHeader().contentType(APPLICATION_JSON)
}
Here the /test
endpoint just returns an empty response with Mono.empty()
.
I have started getting the below error after moving to spring-boot 3.4.0 :
java.lang.AssertionError: Response header 'Content-Type' expected:<application/json> but was:<null>