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:
@@ -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 {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user