Commit b6fbbeccdcc89a2637dcd5f548516edec0a591b0 has updated the PropertySourcesPropertyResolver to check that the targetValueType is a CharSequence or String. This update causes a regression where conversion to other types no longer happens.

See https://github.com/spring-projects/spring-boot/issues/42720 for background and for a reproducer.

I think the targetValueType checks should be removed.

Comment From: snicoll

I think the targetValueType checks should be removed.

Aren't we going to get back to the previous state of the PR, which was also broken?

Comment From: snicoll

Courtesy of @wilkinsona:

I think we need to keep the old logic for String but expand it for CharSequence. Something like this:

if (resolveNestedPlaceholders) {
    if (value instanceof String string) {
        value = resolveNestedPlaceholders(string);
    }
    else if ((value instanceof CharSequence cs) && (String.class.equals(targetValueType)
            || CharSequence.class.equals(targetValueType))) {
        value = resolveNestedPlaceholders(cs.toString());
    }
}