Polish
This commit is contained in:
parent
6ff09bc876
commit
6550bb4cf1
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -288,10 +288,8 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,17 +92,16 @@ 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) {
|
||||||
try {
|
return Collections.<URL>emptyList();
|
||||||
return getUrlsFromClassPathAttribute(jarFile.getManifest());
|
}
|
||||||
}
|
try {
|
||||||
catch (IOException ex) {
|
return getUrlsFromClassPathAttribute(jarFile.getManifest());
|
||||||
throw new IllegalStateException(
|
}
|
||||||
"Failed to read Class-Path attribute from manifest of jar "
|
catch (IOException ex) {
|
||||||
+ url);
|
throw new IllegalStateException(
|
||||||
}
|
"Failed to read Class-Path attribute from manifest of jar " + url);
|
||||||
}
|
}
|
||||||
return Collections.<URL>emptyList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JarFile getJarFileIfPossible(URL url) {
|
private static JarFile getJarFileIfPossible(URL url) {
|
||||||
|
|
@ -119,19 +118,20 @@ 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();
|
||||||
" ")) {
|
}
|
||||||
try {
|
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
|
||||||
urls.add(new URL(entry));
|
List<URL> urls = new ArrayList<URL>(entries.length);
|
||||||
}
|
for (String entry : entries) {
|
||||||
catch (MalformedURLException ex) {
|
try {
|
||||||
throw new IllegalStateException(
|
urls.add(new URL(entry));
|
||||||
"Class-Path attribute contains malformed URL", ex);
|
}
|
||||||
}
|
catch (MalformedURLException ex) {
|
||||||
|
throw new IllegalStateException(
|
||||||
|
"Class-Path attribute contains malformed URL", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return urls;
|
return urls;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue