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

@@ -181,6 +181,9 @@ class ConfigurationClassParser {
String name = propertySource.getString("name");
String[] locations = propertySource.getStringArray("value");
int nLocations = locations.length;
if (nLocations == 0) {
throw new IllegalArgumentException("At least one @PropertySource(value) location is required");
}
for (int i = 0; i < nLocations; i++) {
locations[0] = this.environment.resolveRequiredPlaceholders(locations[0]);
}