From 6550bb4cf16c91b652cf7a98bc94661a673327be Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 7 Apr 2016 12:20:10 -0700 Subject: [PATCH] Polish --- .../OnEnabledEndpointElementCondition.java | 4 +- .../condition/OnBeanCondition.java | 6 +-- .../boot/devtools/restart/ChangeableUrls.java | 44 +++++++++---------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEnabledEndpointElementCondition.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEnabledEndpointElementCondition.java index 06931de70f0..7a3dbc221ef 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEnabledEndpointElementCondition.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/OnEnabledEndpointElementCondition.java @@ -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 */ diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index 800f146f954..2db03cb863e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -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); } } diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java index 9356c4cb4e9..a8587fd0551 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/ChangeableUrls.java @@ -92,17 +92,16 @@ final class ChangeableUrls implements Iterable { private static List 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.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.emptyList(); } private static JarFile getJarFileIfPossible(URL url) { @@ -119,19 +118,20 @@ final class ChangeableUrls implements Iterable { } private static List getUrlsFromClassPathAttribute(Manifest manifest) { - List urls = new ArrayList(); - 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 urls = new ArrayList(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;