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