Skip to content

Spring Boot 4.0.1 - Jackson config in application (YAML/properties) didn't apply to Client HttpMessageConverter #48580

@nico-arianto

Description

@nico-arianto

Case
Jackson, which was declared in the application (YAML/properties), but didn't apply to the Client HttpMessageConverter in Spring Boot 4.0.1

Code:

...
implementation("org.springframework.boot:spring-boot-starter-jackson")
implementation("org.springframework.boot:spring-boot-http-converter")
...
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
...
implementation("tools.jackson.module:jackson-module-kotlin")
...
  jackson:
    datatype:
      enum:
        read_unknown_enum_values_using_default_value: true
    deserialization:
      fail_on_unknown_properties: false
      fail_on_null_for_primitives: false
      use_big_decimal_for_floats: true
    json:
      read:
        allow_java_comments: true
@FeignClient(
    name = "TestFeignClient",
    url = "\${application.test.host}",
)
interface TestFeignClient {
    @PostMapping("/query")
    fun getResponse(request: TestRequest): TestResponse
}
...
data class TestResponse(
  ...
                enum class Status {
                    @JsonAlias("a")
                    A,

                    @JsonEnumDefaultValue
                    O,
                }
  ...
)

Error:

Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `TestResponse$Status` from String "new": not one of the values accepted for Enum class: [O, A, a]

Info
It works correctly in Spring Boot 4.0.0

Read the #48574 document, but it's not clear to me whether, in my case, I also still need to introduce ClientHttpMessageConvertersCustomizer and set it manually from JsonMapper, which is instantiated by Spring Boot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: invalidAn issue that we don't feel is valid

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions