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;
|
||||
|
||||
/**
|
||||
* Base endpoint element condition. An element can be disabled globally via the {@code defaults}
|
||||
* name or individually via the name of the element.
|
||||
* Base endpoint element condition. An element can be disabled globally via the
|
||||
* {@code defaults} name or individually via the name of the element.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -288,10 +288,8 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
|
|||
if (ex == null) {
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(message + " and the attempt to deduce"
|
||||
+ " the bean's type failed", ex);
|
||||
}
|
||||
throw new IllegalStateException(message + " and the attempt to deduce"
|
||||
+ " the bean's type failed", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,17 +92,16 @@ final class ChangeableUrls implements Iterable<URL> {
|
|||
|
||||
private static List<URL> getUrlsFromClassPathOfJarManifestIfPossible(URL url) {
|
||||
JarFile jarFile = getJarFileIfPossible(url);
|
||||
if (jarFile != null) {
|
||||
try {
|
||||
return getUrlsFromClassPathAttribute(jarFile.getManifest());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to read Class-Path attribute from manifest of jar "
|
||||
+ url);
|
||||
}
|
||||
if (jarFile == null) {
|
||||
return Collections.<URL>emptyList();
|
||||
}
|
||||
try {
|
||||
return getUrlsFromClassPathAttribute(jarFile.getManifest());
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to read Class-Path attribute from manifest of jar " + url);
|
||||
}
|
||||
return Collections.<URL>emptyList();
|
||||
}
|
||||
|
||||
private static JarFile getJarFileIfPossible(URL url) {
|
||||
|
|
@ -119,19 +118,20 @@ final class ChangeableUrls implements Iterable<URL> {
|
|||
}
|
||||
|
||||
private static List<URL> getUrlsFromClassPathAttribute(Manifest manifest) {
|
||||
List<URL> urls = new ArrayList<URL>();
|
||||
String classPathAttribute = manifest.getMainAttributes()
|
||||
String classPath = manifest.getMainAttributes()
|
||||
.getValue(Attributes.Name.CLASS_PATH);
|
||||
if (StringUtils.hasText(classPathAttribute)) {
|
||||
for (String entry : StringUtils.delimitedListToStringArray(classPathAttribute,
|
||||
" ")) {
|
||||
try {
|
||||
urls.add(new URL(entry));
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Class-Path attribute contains malformed URL", ex);
|
||||
}
|
||||
if (!StringUtils.hasText(classPath)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String[] entries = StringUtils.delimitedListToStringArray(classPath, " ");
|
||||
List<URL> urls = new ArrayList<URL>(entries.length);
|
||||
for (String entry : entries) {
|
||||
try {
|
||||
urls.add(new URL(entry));
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
throw new IllegalStateException(
|
||||
"Class-Path attribute contains malformed URL", ex);
|
||||
}
|
||||
}
|
||||
return urls;
|
||||
|
|
|
|||
Loading…
Reference in New Issue