Skip to content
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

PropertySourcesPropertyResolver no longer converts to non CharSequence types #33727

Closed
philwebb opened this issue Oct 16, 2024 · 2 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@philwebb
Copy link
Member

Commit b6fbbec 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 spring-projects/spring-boot#42720 for background and for a reproducer.

I think the targetValueType checks should be removed.

@snicoll
Copy link
Member

snicoll commented Oct 17, 2024

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?

@snicoll snicoll added type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 17, 2024
@snicoll snicoll added this to the 6.2.0-RC2 milestone Oct 17, 2024
@snicoll snicoll self-assigned this Oct 17, 2024
@snicoll
Copy link
Member

snicoll commented Oct 17, 2024

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());
    }
}

@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants