diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java index 72029805e7..9325f1057a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/AbstractEndpointDocumentationTests.java @@ -77,13 +77,11 @@ public abstract class AbstractEndpointDocumentationTests { Object target = payload; Map parent = null; for (String key : keys) { - if (target instanceof Map) { - parent = (Map) target; - target = parent.get(key); - } - else { + if (!(target instanceof Map)) { throw new IllegalStateException(); } + parent = (Map) target; + target = parent.get(key); } if (target instanceof Map) { parent.put(keys[keys.length - 1], select((Map) target, filter)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index 6b7affc4bf..3e5dd90424 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -404,9 +404,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext return Arrays.stream(bindConstructor.getParameters()) .anyMatch((parameter) -> parameter.getName().equals(writer.getName())); } - else { - return isReadable(beanDesc, writer); - } + return isReadable(beanDesc, writer); } private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java index 1d7141ec89..51a27cff57 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/util/ResourceUtils.java @@ -152,19 +152,17 @@ public abstract class ResourceUtils { if (location.startsWith(CLASSPATH_URL_PREFIX)) { return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader()); } - else { - if (location.startsWith(FILE_URL_PREFIX)) { - return this.files.getResource(location); - } - try { - // Try to parse the location as a URL... - URL url = new URL(location); - return new UrlResource(url); - } - catch (MalformedURLException ex) { - // No URL -> resolve as resource path. - return getResourceByPath(location); - } + if (location.startsWith(FILE_URL_PREFIX)) { + return this.files.getResource(location); + } + try { + // Try to parse the location as a URL... + URL url = new URL(location); + return new UrlResource(url); + } + catch (MalformedURLException ex) { + // No URL -> resolve as resource path. + return getResourceByPath(location); } } diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java index 3e38b154ee..1ce4ecb91b 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertyMigration.java @@ -127,10 +127,7 @@ class PropertyMigration { return String.format("Reason: Replacement key '%s' uses an incompatible target type", deprecation.getReplacement()); } - else { - return String.format("Reason: No metadata found for replacement key '%s'", - deprecation.getReplacement()); - } + return String.format("Reason: No metadata found for replacement key '%s'", deprecation.getReplacement()); } return "Reason: none"; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java index b7a34606bb..8c6aae0818 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONObject.java @@ -596,12 +596,10 @@ public class JSONObject { */ public JSONArray getJSONArray(String name) throws JSONException { Object object = get(name); - if (object instanceof JSONArray) { - return (JSONArray) object; - } - else { + if (!(object instanceof JSONArray)) { throw JSON.typeMismatch(name, object, "JSONArray"); } + return (JSONArray) object; } /** @@ -625,12 +623,10 @@ public class JSONObject { */ public JSONObject getJSONObject(String name) throws JSONException { Object object = get(name); - if (object instanceof JSONObject) { - return (JSONObject) object; - } - else { + if (!(object instanceof JSONObject)) { throw JSON.typeMismatch(name, object, "JSONObject"); } + return (JSONObject) object; } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONTokener.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONTokener.java index 2a47e73e94..011c69c02d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONTokener.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/json-shade/java/org/springframework/boot/configurationprocessor/json/JSONTokener.java @@ -549,15 +549,13 @@ public class JSONTokener { if (hex >= '0' && hex <= '9') { return hex - '0'; } - else if (hex >= 'A' && hex <= 'F') { + if (hex >= 'A' && hex <= 'F') { return hex - 'A' + 10; } - else if (hex >= 'a' && hex <= 'f') { + if (hex >= 'a' && hex <= 'f') { return hex - 'a' + 10; } - else { - return -1; - } + return -1; } }