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

Property placeholders aren't resolved when configuration property binding creates a Map from a property value using a converter #39471

Closed
ghost opened this issue Feb 8, 2024 · 3 comments
Labels
status: superseded An issue that has been superseded by another

Comments

@ghost
Copy link

ghost commented Feb 8, 2024

When trying to fill an object that implements Map but is valued by a single property via a converter, the MapBinder class does not use a PlaceholderResolver after retrieving the property value. It can be seen in the method bindAggregate.

This result in placeholder not being resolved in the property.

The usecase seems strange, but this is the solution I find to allow multiple way of filing a pseudo Map object from either sub properties or a legacy string format.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 8, 2024
@ghost
Copy link
Author

ghost commented Feb 9, 2024

Just to add some more information.

In the Binder class, when binding a "simple" property :

private <T> Object bindProperty(Bindable<T> target, Context context, ConfigurationProperty property) {
    context.setConfigurationProperty(property);
    Object result = property.getValue();
    result = this.placeholdersResolver.resolvePlaceholders(result);
    result = context.getConverter().convert(result, target);
    return result;
}

We can see the use of the placeholdersResolver.

Meanwhile in the MapBinder class, when binding a property corresponding to a map :

if (property != null && !hasDescendants) {
    getContext().setConfigurationProperty(property);
    return getContext().getConverter().convert(property.getValue(), target);
}

The property is converted but no call to the placeholdersResolver is done.

@wilkinsona wilkinsona changed the title MapBinder doesn't resolve placeholder when creating a map object from a Property placeholders aren't resolved when configuration property binding creates a Map from a property value using a converter Feb 9, 2024
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Feb 9, 2024
@wilkinsona wilkinsona added this to the 3.1.x milestone Feb 9, 2024
@wanger26
Copy link
Contributor

You can assign this one to me, hopefully will have a fix for it shortly.

@scottfrederick
Copy link
Contributor

Closing in favor of #39507

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

No branches or pull requests

4 participants