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

spring-projects-issues opened this issue Sep 20, 2016 · 1 comment


Copy link

@spring-projects-issues 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:

  • #10340 mergePropertiesIntoMap only works with String
  • #17104 Allow YamlProcessor subclasses to build the flattened map
  • #21310 YamlPropertiesFactoryBean loses entries in the YAML document that have an empty array value

Referenced from: commits 74c6188, 3346c59

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 23, 2016

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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants