Polishing

Issue: SPR-11637
This commit is contained in:
Juergen Hoeller
2014-04-09 17:43:09 +02:00
parent d4b0ae9787
commit 0041e245a1
4 changed files with 26 additions and 22 deletions

View File

@@ -305,8 +305,7 @@ class ConfigurationClassParser {
String name = propertySource.getString("name");
String[] locations = propertySource.getStringArray("value");
boolean ignoreResourceNotFound = propertySource.getBoolean("ignoreResourceNotFound");
int locationCount = locations.length;
if (locationCount == 0) {
if (locations.length == 0) {
throw new IllegalArgumentException("At least one @PropertySource(value) location is required");
}
for (String location : locations) {
@@ -314,8 +313,7 @@ class ConfigurationClassParser {
Resource resource = this.resourceLoader.getResource(
this.environment.resolveRequiredPlaceholders(location));
if (!StringUtils.hasText(name) || this.propertySources.containsKey(name)) {
// We need to ensure unique names when the property source will
// ultimately end up in a composite
// We need to ensure unique names when the property source will ultimately end up in a composite
ResourcePropertySource ps = new ResourcePropertySource(resource);
this.propertySources.add((StringUtils.hasText(name) ? name : ps.getName()), ps);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -307,7 +307,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
"Reason: Environment must implement ConfigurableEnvironment");
}
else {
MutablePropertySources envPropertySources = ((ConfigurableEnvironment)this.environment).getPropertySources();
MutablePropertySources envPropertySources = ((ConfigurableEnvironment) this.environment).getPropertySources();
for (PropertySource<?> propertySource : parsedPropertySources) {
envPropertySources.addLast(propertySource);
}