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

YAML + PropertyPlaceholderConfigurer needs to process non-String values as well [SPR-14737] #19303

Closed
spring-projects-issues opened this issue Sep 20, 2016 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 20, 2016

Dennis Mellert opened SPR-14737 and commented

When loading a Yaml resource (using YamlPropertiesFactoryBean) and passing it to a PropertyPlaceholderConfigurer (using <property name="properties" ref="yamlProperties" />) only String in the Yaml are replaced correctly.

The Problem seems to be that org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperties(Properties) only handles Strings (String propertyValue = props.getProperty(propertyName);). Since the propertyValue is not a String in this case (as parsed from YamlPropertiesFactoryBean, the method call returns null.

Workaround: Overriding convertProperties and dealing with propertyValues as Object: (Object propertyValue = props.get(propertyName);


Affects: 4.3.3

Issue Links:

Referenced from: commits 74c6188, 3346c59

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Good point. I've approached this a bit differently: YamlPropertiesFactoryBean exposes a Properties object with an overridden getProperty method which consistently exposes stringified representations now instead of silently swallowing non-String values.

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants