最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

contentType header in response set to null when returning empty response after spring-boot 3.4.0 - Stack Overflow

programmeradmin0浏览0评论

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>

发布评论

评论列表(0)

  1. 暂无评论