This commit is contained in:
Phillip Webb 2016-04-07 12:20:10 -07:00
parent 6ff09bc876
commit 6550bb4cf1
3 changed files with 26 additions and 28 deletions

View File

@ -24,8 +24,8 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
/** /**
* Base endpoint element condition. An element can be disabled globally via the {@code defaults} * Base endpoint element condition. An element can be disabled globally via the
* name or individually via the name of the element. * {@code defaults} name or individually via the name of the element.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */

View File

@ -288,12 +288,10 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
if (ex == null) { if (ex == null) {
throw new IllegalStateException(message); throw new IllegalStateException(message);
} }
else {
throw new IllegalStateException(message + " and the attempt to deduce" throw new IllegalStateException(message + " and the attempt to deduce"
+ " the bean's type failed", ex); + " the bean's type failed", ex);
} }
} }
}
private boolean hasAtLeastOne(List<?>... lists) { private boolean hasAtLeastOne(List<?>... lists) {
for (List<?> list : lists) { for (List<?> list : lists) {

View File

@ -92,18 +92,17 @@ final class ChangeableUrls implements Iterable<URL> {
private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) { private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) {
JarFile jarFile = getJarFileIfPossible(url); JarFile jarFile = getJarFileIfPossible(url);
if (jarFile != null) { if (jarFile == null) {
return Collections.<URL>emptyList();
}
try { try {
return getUrlsFromClassPathAttribute(jarFile.getManifest()); return getUrlsFromClassPathAttribute(jarFile.getManifest());
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalStateException( throw new IllegalStateException(
"Failed to read Class-Path attribute from manifest of jar " "Failed to read Class-Path attribute from manifest of jar " + url);
+ url);
} }
} }
return Collections.<URL>emptyList();
}
private static JarFile getJarFileIfPossible(URL url) { private static JarFile getJarFileIfPossible(URL url) {
try { try {
@ -119,12 +118,14 @@ final class ChangeableUrls implements Iterable<URL> {
} }
private static List<URL> getUrlsFromClassPathAttribute(Manifest manifest) { private static List<URL> getUrlsFromClassPathAttribute(Manifest manifest) {
List<URL> urls = new ArrayList<URL>(); String classPath = manifest.getMainAttributes()
String classPathAttribute = manifest.getMainAttributes()
.getValue(Attributes.Name.CLASS_PATH); .getValue(Attributes.Name.CLASS_PATH);
if (StringUtils.hasText(classPathAttribute)) { if (!StringUtils.hasText(classPath)) {
for (String entry : StringUtils.delimitedListToStringArray(classPathAttribute, return Collections.emptyList();
" ")) { }
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
List<URL> urls = new ArrayList<URL>(entries.length);
for (String entry : entries) {
try { try {
urls.add(new URL(entry)); urls.add(new URL(entry));
} }
@ -133,7 +134,6 @@ final class ChangeableUrls implements Iterable<URL> {
"Class-Path attribute contains malformed URL", ex); "Class-Path attribute contains malformed URL", ex);
} }
} }
}
return urls; return urls;
} }