Skip to content

@ConfigurationPropertiesBinding converters are not invoked for target types that can be converted by ObjectToObjectConverter #34631

Closed
@adase11

Description

@adase11

I noticed for an application that I was working on that a Converter that I registered via @ConfigurationPropertiesBinding for a class that was a simple wrapper around a String ( i.e. record SimpleWrapper(String value) {}) was not actually invoked. (In my actual application I needed to do some logic to transform the String).

While the Converter for the class when it was a simple wrapper around a String was not invoked, if I made the target class more complex (i.e. record ComplexWrapper(String value, BigDecimal other) {} ) than the converter was invoked. I believe that no matter the type or number of members of the target class that the Converter should always be invoked.

I created a quick demo application to demonstrate the issue (trying to stay to as true to the way the application I am working on is structured while also being as generic as possible). See https://github.com/adase11/property-converter-demo

Specifically the test PropertyConverterDemoApplicationTest
should demonstrate the behavior.

Interestingly, as demonstrated in the test, the behavior is only reproducible by starting up a full application context. My attempts to recreate the behavior with org.springframework.boot.test.context.runner.ApplicationContextRunner were unsucessful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions