Disallow empty @PropertySource(value = {})

Previously, a user could specify an empty array of resource locations
to the @PropertySource annotation, which amounts to a meaningless no-op.

ConfigurationClassParser now throws IllegalArgumentException upon
encountering any such misconfiguration.
This commit is contained in:
Chris Beams
2012-02-16 18:05:12 +01:00
parent 41ade68b50
commit 80dd32e95c
2 changed files with 14 additions and 9 deletions

View File

@@ -130,15 +130,11 @@ public class PropertySourceAnnotationTests {
assertThat(ctx.getEnvironment().containsProperty("from.p2"), is(true));
}
@Configuration
@PropertySource(
name = "psName",
value = {
"classpath:org/springframework/context/annotation/p1.properties",
"classpath:org/springframework/context/annotation/p2.properties"
})
static class ConfigWithNameAndMultipleResourceValues {
@Test(expected=IllegalArgumentException.class)
public void withEmptyResourceLocations() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.register(ConfigWithEmptyResourceLocations.class);
ctx.refresh();
}
@@ -212,4 +208,10 @@ public class PropertySourceAnnotationTests {
})
static class ConfigWithNameAndMultipleResourceLocations {
}
@Configuration
@PropertySource(value = {})
static class ConfigWithEmptyResourceLocations {
}
}