You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Spring Boot 1.5.2.RELEASE I have a String property that is mapped to an application.yml by @ConfigurationProperties. The value in the yml file is null (or ~). But the values are initialized with "" (empty String). According to YAML specification it does allow null values.
The "culprit" is org.springframework.beans.factory.config.YamlProcessor#buildFlattenedMap which executes result.put(key, (value != null ? value : ""))
I've extended the file and configured it to be used and this seems to work fine. But I have to take over a lot of final and private code which makes it a bit brittle. I think Spring should support null values, explicitly remark that their converted to "" or make a change in behavior a bit more comfortable.
Code excerpts:
test:
setting: ~
@ConfigurationProperties("test")
public class Test {
String setting;
public void setSetting(String setting) {
this.setting = setting; //Will set "setting" to "" instead of null
}
}
@theotherp The code that you have identified is part of Spring Framework rather than Spring Boot. If you'd like to pursue this change, please open a Spring Framework JIRA ticket.
Oops, sorry. I should've seen that looking at the package name but because it's a problem that affects externalized configuration I thought it would fit here.
Nevertheless I think this should be mentioned in Spring Boot's documentation.
With Spring Boot 1.5.2.RELEASE I have a String property that is mapped to an application.yml by
@ConfigurationProperties.
The value in the yml file isnull
(or~
). But the values are initialized with "" (empty String). According to YAML specification it does allow null values.The "culprit" is org.springframework.beans.factory.config.YamlProcessor#buildFlattenedMap which executes
result.put(key, (value != null ? value : ""))
I've extended the file and configured it to be used and this seems to work fine. But I have to take over a lot of final and private code which makes it a bit brittle. I think Spring should support null values, explicitly remark that their converted to "" or make a change in behavior a bit more comfortable.
Code excerpts:
Thanks for your time.
demo.zip
The text was updated successfully, but these errors were encountered: