Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nipanwar77 opened this issue Apr 7, 2025 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@nipanwar77
Copy link

nipanwar77 commented Apr 7, 2025

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>

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 7, 2025
@bclozel bclozel transferred this issue from spring-projects/spring-boot Apr 7, 2025
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Apr 7, 2025
@bclozel bclozel self-assigned this Apr 8, 2025
@deepakraghav0
Copy link

Hello @bclozel did you get a chance to look into this issue?

@bclozel
Copy link
Member

bclozel commented Apr 10, 2025

I can indeed reproduce the behavior change you are seeing. This was reported and fixed in #32622.

I updated the release notes accordingly to mention this change.

Thanks!

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2025
@bclozel bclozel removed their assignment Apr 10, 2025
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on in: web Issues in web modules (web, webmvc, webflux, websocket) labels Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

5 participants