Skip to content

Undocumented Breaking Change: contentType header in response set to null when returning empty response after spring-boot 3.4.0Β #34725

Closed as not planned
@nipanwar77

Description

@nipanwar77

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 or any breaking change mentioned for the same.

Ex :

    @Test
    fun `should work`() {
        webTestClient.post()
                .uri("/test")
                .header(CONTENT_TYPE, APPLICATION_JSON_VALUE)
                .bodyValue("""{"some": "test"}""")
                .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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions