Andy Wilkinson opened SPR-16769 and commented
This is related to #19986, although I think this issue is a bug rather than an enhancement.
YamlPropertiesFactoryBean handles an entry with an empty value differently to an entry with a value that is an empty array. An empty value becomes an empty string in the resulting Properties whereas the entry with an empty array value doesn't appear in the Properties at all.
Here are four tests that show this difference in behaviour (as well as the behaviour of YamlMapFactoryBean:
@Test
public void mapWithEmptyArrayValue() throws IOException {
YamlMapFactoryBean factory = new YamlMapFactoryBean();
factory.setResources(new ByteArrayResource("a: alpha\ntest: []".getBytes()));
factory.afterPropertiesSet();
assertThat(factory.getObject()).containsKey("test");
}
@Test
public void mapWithEmptyValue() throws IOException {
YamlMapFactoryBean factory = new YamlMapFactoryBean();
factory.setResources(new ByteArrayResource("a: alpha\ntest:".getBytes()));
factory.afterPropertiesSet();
assertThat(factory.getObject()).containsKey("test");
}
@Test
public void propertiesWithEmptyArrayValue() throws IOException {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("a: alpha\ntest: []".getBytes()));
factory.afterPropertiesSet();
assertThat(factory.getObject()).containsKey("test");
}
@Test
public void propertiesWithEmptyValue() throws IOException {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("a: alpha\ntest:".getBytes()));
factory.afterPropertiesSet();
assertThat(factory.getObject()).containsKey("test");
}
propertiesWithEmptyArrayValue fails due to the entry being lost.
Affects: 4.3.16, 5.0.5
Reference URL: spring-projects/spring-boot#12965
Issue Links:
Referenced from: commits 43f2334, e51330e
Andy Wilkinson opened SPR-16769 and commented
This is related to #19986, although I think this issue is a bug rather than an enhancement.
YamlPropertiesFactoryBeanhandles an entry with an empty value differently to an entry with a value that is an empty array. An empty value becomes an empty string in the resultingPropertieswhereas the entry with an empty array value doesn't appear in thePropertiesat all.Here are four tests that show this difference in behaviour (as well as the behaviour of
YamlMapFactoryBean:propertiesWithEmptyArrayValuefails due to the entry being lost.Affects: 4.3.16, 5.0.5
Reference URL: spring-projects/spring-boot#12965
Issue Links:
Referenced from: commits 43f2334, e51330e