diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java index 0188d84e633..72c6f9973f7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundrySecurityService.java @@ -111,7 +111,7 @@ class CloudFoundrySecurityService { return extractTokenKeys(this.restTemplate .getForObject(getUaaUrl() + "/token_keys", Map.class)); } - catch (HttpStatusCodeException e) { + catch (HttpStatusCodeException ex) { throw new CloudFoundryAuthorizationException(Reason.SERVICE_UNAVAILABLE, "UAA not reachable"); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java index 76eb49d5051..08f705f55b8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java @@ -175,8 +175,8 @@ public class ConditionsReportEndpoint { public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) { for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) { - List target = conditionAndOutcome.getOutcome() - .isMatch() ? this.matched : this.notMatched; + List target = (conditionAndOutcome.getOutcome() + .isMatch() ? this.matched : this.notMatched); target.add(new MessageAndCondition(conditionAndOutcome)); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java index 87e4aba942b..528979623de 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java @@ -132,9 +132,9 @@ class ManagementContextConfigurationImportSelector private int readOrder(AnnotationMetadata annotationMetadata) { Map attributes = annotationMetadata .getAnnotationAttributes(Order.class.getName()); - Integer order = (attributes == null ? null - : (Integer) attributes.get("value")); - return (order == null ? Ordered.LOWEST_PRECEDENCE : order); + Integer order = (attributes != null ? (Integer) attributes.get("value") + : null); + return (order != null ? order : Ordered.LOWEST_PRECEDENCE); } public String getClassName() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java index 9a05319486e..a459b0d21fb 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java @@ -98,7 +98,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator { public int compare(Status s1, Status s2) { int i1 = this.statusOrder.indexOf(s1.getCode()); int i2 = this.statusOrder.indexOf(s2.getCode()); - return (i1 < i2 ? -1 : (i1 == i2 ? s1.getCode().compareTo(s2.getCode()) : 1)); + return (i1 < i2 ? -1 : (i1 != i2 ? 1 : s1.getCode().compareTo(s2.getCode()))); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java index 8e9fff7097b..a44ebae8a1b 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java @@ -112,7 +112,7 @@ public class LoggersEndpoint { } private String getName(LogLevel level) { - return (level == null ? null : level.name()); + return (level != null ? level.name() : null); } public String getConfiguredLevel() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java index dd686a56b71..e88969ccc6a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java @@ -48,7 +48,7 @@ public class SolrHealthIndicator extends AbstractHealthIndicator { request.setAction(CoreAdminParams.CoreAdminAction.STATUS); CoreAdminResponse response = request.process(this.solrClient); int statusCode = response.getStatus(); - Status status = (statusCode == 0 ? Status.UP : Status.DOWN); + Status status = (statusCode != 0 ? Status.DOWN : Status.UP); builder.status(status).withDetail("status", statusCode); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java index 03db0461168..dadd0faba16 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java @@ -225,7 +225,7 @@ public class AutoConfigurationImportSelector } String[] excludes = getEnvironment() .getProperty(PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE, String[].class); - return (excludes == null ? Collections.emptyList() : Arrays.asList(excludes)); + return (excludes != null ? Arrays.asList(excludes) : Collections.emptyList()); } private List filter(List configurations, @@ -273,7 +273,7 @@ public class AutoConfigurationImportSelector protected final List asList(AnnotationAttributes attributes, String name) { String[] value = attributes.getStringArray(name); - return Arrays.asList(value == null ? new String[0] : value); + return Arrays.asList(value != null ? value : new String[0]); } private void fireAutoConfigurationImportEvents(List configurations, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java index d31fbd8a3c6..833f5298e91 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java @@ -213,8 +213,8 @@ class AutoConfigurationSorter { } Map attributes = getAnnotationMetadata() .getAnnotationAttributes(AutoConfigureOrder.class.getName()); - return (attributes == null ? AutoConfigureOrder.DEFAULT_ORDER - : (Integer) attributes.get("value")); + return (attributes != null ? (Integer) attributes.get("value") + : AutoConfigureOrder.DEFAULT_ORDER); } private boolean wasProcessed() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java index 0def58b5c08..ce0f019c794 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java @@ -109,8 +109,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec for (String annotationName : ANNOTATION_NAMES) { AnnotationAttributes merged = AnnotatedElementUtils .getMergedAnnotationAttributes(source, annotationName); - Class[] exclude = (merged == null ? null - : merged.getClassArray("exclude")); + Class[] exclude = (merged != null ? merged.getClassArray("exclude") + : null); if (exclude != null) { for (Class excludeClass : exclude) { exclusions.add(excludeClass.getName()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 7d1a2420099..5d97dab62e7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -206,7 +206,7 @@ public class RabbitProperties { return this.username; } Address address = this.parsedAddresses.get(0); - return address.username == null ? this.username : address.username; + return (address.username != null ? address.username : this.username); } public void setUsername(String username) { @@ -229,7 +229,7 @@ public class RabbitProperties { return getPassword(); } Address address = this.parsedAddresses.get(0); - return address.password == null ? getPassword() : address.password; + return (address.password != null ? address.password : getPassword()); } public void setPassword(String password) { @@ -256,7 +256,7 @@ public class RabbitProperties { return getVirtualHost(); } Address address = this.parsedAddresses.get(0); - return address.virtualHost == null ? getVirtualHost() : address.virtualHost; + return (address.virtualHost != null ? address.virtualHost : getVirtualHost()); } public void setVirtualHost(String virtualHost) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java index efb54aac71b..b8381eb320b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java @@ -124,7 +124,7 @@ public class CacheAutoConfiguration { } private String[] append(String[] array, String value) { - String[] result = new String[array == null ? 1 : array.length + 1]; + String[] result = new String[array != null ? array.length + 1 : 1]; if (array != null) { System.arraycopy(array, 0, result, 0, array.length); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index 6852f79cf90..4e9c1769942 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -285,9 +285,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { private Method[] getCandidateFactoryMethods(BeanDefinition definition, Class factoryClass) { - return shouldConsiderNonPublicMethods(definition) + return (shouldConsiderNonPublicMethods(definition) ? ReflectionUtils.getAllDeclaredMethods(factoryClass) - : factoryClass.getMethods(); + : factoryClass.getMethods()); } private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index a1181bed38b..07283b11c5c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -61,7 +61,7 @@ public final class ConditionMessage { @Override public String toString() { - return (this.message == null ? "" : this.message); + return (this.message != null ? this.message : ""); } @Override @@ -358,7 +358,7 @@ public final class ConditionMessage { * @return a built {@link ConditionMessage} */ public ConditionMessage items(Style style, Object... items) { - return items(style, items == null ? null : Arrays.asList(items)); + return items(style, items != null ? Arrays.asList(items) : null); } /** @@ -415,7 +415,7 @@ public final class ConditionMessage { QUOTE { @Override protected String applyToItem(Object item) { - return (item == null ? null : "'" + item + "'"); + return (item != null ? "'" + item + "'" : null); } }; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java index 1dee310654d..e83ae08c04e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java @@ -146,7 +146,7 @@ public class ConditionOutcome { @Override public String toString() { - return (this.message == null ? "" : this.message.toString()); + return (this.message != null ? this.message.toString() : ""); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index 5b0573ae4a0..d6460a03f85 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -284,7 +284,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit collectBeanNamesForAnnotation(names, beanFactory, annotationType, considerHierarchy); } - catch (ClassNotFoundException e) { + catch (ClassNotFoundException ex) { // Continue } return StringUtils.toStringArray(names); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java index 41310de7182..a0610904b8f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java @@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition { String rawExpression = expression; expression = context.getEnvironment().resolvePlaceholders(expression); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - BeanExpressionResolver resolver = (beanFactory != null) - ? beanFactory.getBeanExpressionResolver() : null; - BeanExpressionContext expressionContext = (beanFactory != null) - ? new BeanExpressionContext(beanFactory, null) : null; + BeanExpressionResolver resolver = (beanFactory != null + ? beanFactory.getBeanExpressionResolver() : null); + BeanExpressionContext expressionContext = (beanFactory != null + ? new BeanExpressionContext(beanFactory, null) : null); if (resolver == null) { resolver = new StandardBeanExpressionResolver(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java index 62e5ab0b179..1f0036eec61 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java @@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition { JavaVersion version) { boolean match = isWithin(runningVersion, range, version); String expected = String.format( - range == Range.EQUAL_OR_NEWER ? "(%s or newer)" : "(older than %s)", + range != Range.EQUAL_OR_NEWER ? "(older than %s)" : "(%s or newer)", version); ConditionMessage message = ConditionMessage .forCondition(ConditionalOnJava.class, expected) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java index 3c54c1dc554..25782601101 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java @@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition { AnnotatedTypeMetadata metadata) { MultiValueMap attributes = metadata .getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true); - ResourceLoader loader = context.getResourceLoader() == null - ? this.defaultResourceLoader : context.getResourceLoader(); + ResourceLoader loader = (context.getResourceLoader() != null + ? context.getResourceLoader() : this.defaultResourceLoader); List locations = new ArrayList<>(); collectValues(locations, attributes.get("resources")); Assert.isTrue(!locations.isEmpty(), diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java index aae26aa7d68..4bfd5770516 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java @@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer cause); StringBuilder message = new StringBuilder(); message.append(String.format("%s required %s that could not be found.%n", - description == null ? "A component" : description, + (description != null ? description : "A component"), getBeanDescription(cause))); if (!autoConfigurationResults.isEmpty()) { for (AutoConfigurationResult provider : autoConfigurationResults) { @@ -169,7 +169,7 @@ class NoSuchBeanDefinitionFailureAnalyzer Source(String source) { String[] tokens = source.split("#"); this.className = (tokens.length > 1 ? tokens[0] : source); - this.methodName = (tokens.length == 2 ? tokens[1] : null); + this.methodName = (tokens.length != 2 ? null : tokens[1]); } public String getClassName() { @@ -229,8 +229,8 @@ class NoSuchBeanDefinitionFailureAnalyzer private boolean hasName(MethodMetadata methodMetadata, String name) { Map attributes = methodMetadata .getAnnotationAttributes(Bean.class.getName()); - String[] candidates = (attributes == null ? null - : (String[]) attributes.get("name")); + String[] candidates = (attributes != null ? (String[]) attributes.get("name") + : null); if (candidates != null) { for (String candidate : candidates) { if (candidate.equals(name)) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index 91d649b2bf0..5ca3a78cc1f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -109,7 +109,7 @@ public class FlywayProperties { } public String getPassword() { - return (this.password == null ? "" : this.password); + return (this.password != null ? this.password : ""); } public void setPassword(String password) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java index f20ecc3fb03..790deec4d47 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java @@ -104,7 +104,7 @@ public class HttpEncodingProperties { } public boolean shouldForce(Type type) { - Boolean force = (type == Type.REQUEST ? this.forceRequest : this.forceResponse); + Boolean force = (type != Type.REQUEST ? this.forceResponse : this.forceRequest); if (force == null) { force = this.force; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java index 7524220e5ec..b0d90a5f6da 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java @@ -69,7 +69,7 @@ public class HttpMessageConvertersAutoConfiguration { @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { return new HttpMessageConverters( - this.converters == null ? Collections.emptyList() : this.converters); + this.converters != null ? this.converters : Collections.emptyList()); } @Configuration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java index bd874bfbf8d..11ed13c74e1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java @@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration { } protected Properties loadFrom(Resource location, String prefix) throws IOException { - String p = prefix.endsWith(".") ? prefix : prefix + "."; + String p = (prefix.endsWith(".") ? prefix : prefix + "."); Properties source = PropertiesLoaderUtils.loadProperties(location); Properties target = new Properties(); for (String key : source.stringPropertyNames()) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index 3f0ba38045d..ccf9e557af5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java @@ -121,7 +121,7 @@ public class DataSourceAutoConfiguration { private ClassLoader getDataSourceClassLoader(ConditionContext context) { Class dataSourceClass = DataSourceBuilder .findType(context.getClassLoader()); - return (dataSourceClass == null ? null : dataSourceClass.getClassLoader()); + return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java index 8152bc82ef5..62ac67b8294 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java @@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware { if (!applicationPath.startsWith("/")) { applicationPath = "/" + applicationPath; } - return applicationPath.equals("/") ? "/*" : applicationPath + "/*"; + return (applicationPath.equals("/") ? "/*" : applicationPath + "/*"); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index 148780bb28d..27020816112 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -257,7 +257,7 @@ public class EmbeddedMongoAutoConfiguration { Set features) { Assert.notNull(version, "version must not be null"); this.version = version; - this.features = (features == null ? Collections.emptySet() : features); + this.features = (features != null ? features : Collections.emptySet()); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java index 3e729ab93f5..506d185dfa0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java @@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders { * @param applicationContext the source application context */ public TemplateAvailabilityProviders(ApplicationContext applicationContext) { - this(applicationContext == null ? null : applicationContext.getClassLoader()); + this(applicationContext != null ? applicationContext.getClassLoader() : null); } /** @@ -143,12 +143,12 @@ public class TemplateAvailabilityProviders { if (provider == null) { synchronized (this.cache) { provider = findProvider(view, environment, classLoader, resourceLoader); - provider = (provider == null ? NONE : provider); + provider = (provider != null ? provider : NONE); this.resolved.put(view, provider); this.cache.put(view, provider); } } - return (provider == NONE ? null : provider); + return (provider != NONE ? provider : null); } private TemplateAvailabilityProvider findProvider(String view, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java index e3b899b663d..7f282437a6e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java @@ -91,7 +91,7 @@ public class BasicErrorController extends AbstractErrorController { request, isIncludeStackTrace(request, MediaType.TEXT_HTML))); response.setStatus(status.value()); ModelAndView modelAndView = resolveErrorView(request, response, status, model); - return (modelAndView == null ? new ModelAndView("error", model) : modelAndView); + return (modelAndView != null ? modelAndView : new ModelAndView("error", model)); } @RequestMapping diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java index 8948605bd3f..25c81e2e9f1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java @@ -311,11 +311,11 @@ public class ErrorMvcAutoConfiguration { @Override public String resolvePlaceholder(String placeholderName) { Expression expression = this.expressions.get(placeholderName); - return escape(expression == null ? null : expression.getValue(this.context)); + return escape(expression != null ? expression.getValue(this.context) : null); } private String escape(Object value) { - return HtmlUtils.htmlEscape(value == null ? null : value.toString()); + return HtmlUtils.htmlEscape(value != null ? value.toString() : null); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java index 6aa2bf91cd0..a466688de82 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java @@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer private Manifest getManifest(ServletContext servletContext) throws IOException { InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"); - return (stream == null ? null : new Manifest(stream)); + return (stream != null ? new Manifest(stream) : null); } @Override diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java index 29b23807d1e..1a0e202e3d7 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java @@ -260,7 +260,7 @@ public class CommandRunner implements Iterable { } protected boolean errorMessage(String message) { - Log.error(message == null ? "Unexpected error" : message); + Log.error(message != null ? message : "Unexpected error"); return message != null; } @@ -280,8 +280,8 @@ public class CommandRunner implements Iterable { String usageHelp = command.getUsageHelp(); String description = command.getDescription(); Log.info(String.format("%n %1$s %2$-15s%n %3$s", command.getName(), - (usageHelp == null ? "" : usageHelp), - (description == null ? "" : description))); + (usageHelp != null ? usageHelp : ""), + (description != null ? description : ""))); } } Log.info(""); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java index 3476da3a504..84fb7a60957 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java @@ -230,7 +230,7 @@ abstract class ArchiveCommand extends OptionParsingCommand { private String commaDelimitedClassNames(Class[] classes) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < classes.length; i++) { - builder.append(i == 0 ? "" : ","); + builder.append(i != 0 ? "," : ""); builder.append(classes[i].getName()); } return builder.toString(); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java index ea62820f2c8..c101cf71250 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java @@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand { } Collection examples = command.getExamples(); if (examples != null) { - Log.info(examples.size() == 1 ? "example:" : "examples:"); + Log.info(examples.size() != 1 ? "examples:" : "example:"); Log.info(""); for (HelpExample example : examples) { Log.info(" " + example.getDescription() + ":"); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java index 0f01a9c202d..5eef4fd9484 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java @@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand { @Override public ExitStatus run(String... args) throws Exception { try { - int index = (args.length == 0 ? 0 : Integer.valueOf(args[0]) - 1); + int index = (args.length != 0 ? Integer.valueOf(args[0]) - 1 : 0); List arguments = new ArrayList<>(args.length); for (int i = 2; i < args.length; i++) { arguments.add(args[i]); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java index 97d953c84eb..aee43aba192 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java @@ -149,8 +149,8 @@ class InitializrServiceMetadata { } JSONObject type = root.getJSONObject(TYPE_EL); JSONArray array = type.getJSONArray(VALUES_EL); - String defaultType = type.has(DEFAULT_ATTRIBUTE) - ? type.getString(DEFAULT_ATTRIBUTE) : null; + String defaultType = (type.has(DEFAULT_ATTRIBUTE) + ? type.getString(DEFAULT_ATTRIBUTE) : null); for (int i = 0; i < array.length(); i++) { JSONObject typeJson = array.getJSONObject(i); ProjectType projectType = parseType(typeJson, defaultType); @@ -212,7 +212,7 @@ class InitializrServiceMetadata { private String getStringValue(JSONObject object, String name, String defaultValue) throws JSONException { - return object.has(name) ? object.getString(name) : defaultValue; + return (object.has(name) ? object.getString(name) : defaultValue); } private Map parseStringItems(JSONObject json) throws JSONException { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index aaa394a6003..9be203c8f00 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -358,8 +358,8 @@ class ProjectGenerationRequest { return builder.build(); } - catch (URISyntaxException e) { - throw new ReportableException("Invalid service URL (" + e.getMessage() + ")"); + catch (URISyntaxException ex) { + throw new ReportableException("Invalid service URL (" + ex.getMessage() + ")"); } } @@ -415,7 +415,7 @@ class ProjectGenerationRequest { } if (this.output != null) { int i = this.output.lastIndexOf('.'); - return (i == -1 ? this.output : this.output.substring(0, i)); + return (i != -1 ? this.output.substring(0, i) : this.output); } return null; } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java index 218740ac4c5..db0a2236ee3 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java @@ -157,7 +157,7 @@ public class OptionHandler { OptionHelpAdapter(OptionDescriptor descriptor) { this.options = new LinkedHashSet<>(); for (String option : descriptor.options()) { - this.options.add((option.length() == 1 ? "-" : "--") + option); + this.options.add((option.length() != 1 ? "--" : "-") + option); } if (this.options.contains("--cp")) { this.options.remove("--cp"); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java index e741eea27db..13e1d7e8d9f 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java @@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter { public int complete(String buffer, int cursor, List candidates) { int completionIndex = super.complete(buffer, cursor, candidates); int spaceIndex = buffer.indexOf(' '); - String commandName = (spaceIndex == -1) ? "" : buffer.substring(0, spaceIndex); + String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); if (!"".equals(commandName.trim())) { for (Command command : this.commands) { if (command.getName().equals(commandName)) { @@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter { OptionHelpLine(OptionHelp optionHelp) { StringBuilder options = new StringBuilder(); for (String option : optionHelp.getOptions()) { - options.append(options.length() == 0 ? "" : ", "); + options.append(options.length() != 0 ? ", " : ""); options.append(option); } this.options = options.toString(); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java index 1edac65ab45..3edd30777e6 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java @@ -140,7 +140,7 @@ public class Shell { private void printBanner() { String version = getClass().getPackage().getImplementationVersion(); - version = (version == null ? "" : " (v" + version + ")"); + version = (version != null ? " (v" + version + ")" : ""); System.out.println(ansi("Spring Boot", Code.BOLD).append(version, Code.FAINT)); System.out.println(ansi("Hit TAB to complete. Type 'help' and hit " + "RETURN for help, and 'exit' to quit.")); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java index 793e66ea039..19d41d429e7 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java @@ -54,7 +54,7 @@ public class ShellPrompts { * @return the current prompt */ public String getPrompt() { - return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek(); + return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek()); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java index 76ad2d53052..848478ded3d 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyManagementBomTransformation.java @@ -222,8 +222,8 @@ public class DependencyManagementBomTransformation return new UrlModelSource( Grape.getInstance().resolve(null, dependency)[0].toURL()); } - catch (MalformedURLException e) { - throw new UnresolvableModelException(e.getMessage(), groupId, artifactId, + catch (MalformedURLException ex) { + throw new UnresolvableModelException(ex.getMessage(), groupId, artifactId, version); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java index 5e16696e9e9..22bc88a63e8 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java @@ -115,7 +115,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader { InputStream resourceStream = super.getResourceAsStream(name); if (resourceStream == null) { byte[] bytes = this.classResources.get(name); - resourceStream = bytes == null ? null : new ByteArrayInputStream(bytes); + resourceStream = (bytes != null ? new ByteArrayInputStream(bytes) : null); } return resourceStream; } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java index f61b6a256b2..2bb1a7517c1 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java @@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver @Override public String getGroupId(String artifactId) { Dependency dependency = find(artifactId); - return (dependency == null ? null : dependency.getGroupId()); + return (dependency != null ? dependency.getGroupId() : null); } @Override public String getArtifactId(String id) { Dependency dependency = find(id); - return dependency == null ? null : dependency.getArtifactId(); + return (dependency != null ? dependency.getArtifactId() : null); } private Dependency find(String id) { @@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver @Override public String getVersion(String module) { Dependency dependency = find(module); - return dependency == null ? null : dependency.getVersion(); + return (dependency != null ? dependency.getVersion() : null); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index abb9f16c297..eec15605b86 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -197,7 +197,7 @@ public class AetherGrapeEngine implements GrapeEngine { private boolean isTransitive(Map dependencyMap) { Boolean transitive = (Boolean) dependencyMap.get("transitive"); - return (transitive == null ? true : transitive); + return (transitive != null ? transitive : true); } private List getDependencies(DependencyResult dependencyResult) { @@ -219,7 +219,7 @@ public class AetherGrapeEngine implements GrapeEngine { private GroovyClassLoader getClassLoader(Map args) { GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader"); - return (classLoader == null ? this.classLoader : classLoader); + return (classLoader != null ? classLoader : this.classLoader); } @Override diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java index 6d0d9981c97..75ba927636c 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java @@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration ProxySelector existing = session.getProxySelector(); if (existing == null || !(existing instanceof CompositeProxySelector)) { JreProxySelector fallback = new JreProxySelector(); - ProxySelector selector = existing == null ? fallback - : new CompositeProxySelector(Arrays.asList(existing, fallback)); + ProxySelector selector = (existing != null + ? new CompositeProxySelector(Arrays.asList(existing, fallback)) + : fallback); session.setProxySelector(selector); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java index ff0570b442e..f7d0773a281 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java @@ -67,7 +67,7 @@ public class DependencyResolutionContext { dependency = this.managedDependencyByGroupAndArtifact .get(getIdentifier(groupId, artifactId)); } - return dependency != null ? dependency.getArtifact().getVersion() : null; + return (dependency != null ? dependency.getArtifact().getVersion() : null); } public List getManagedDependencies() { @@ -104,9 +104,10 @@ public class DependencyResolutionContext { this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency), aetherDependency); } - this.dependencyManagement = this.dependencyManagement == null - ? dependencyManagement : new CompositeDependencyManagement( - dependencyManagement, this.dependencyManagement); + this.dependencyManagement = (this.dependencyManagement != null + ? new CompositeDependencyManagement(dependencyManagement, + this.dependencyManagement) + : dependencyManagement); this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver( this.dependencyManagement); } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettingsReader.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettingsReader.java index a9c4f2d6cb4..270fd20b768 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettingsReader.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettingsReader.java @@ -116,8 +116,8 @@ public class MavenSettingsReader { try { this._cipher = new DefaultPlexusCipher(); } - catch (PlexusCipherException e) { - throw new IllegalStateException(e); + catch (PlexusCipherException ex) { + throw new IllegalStateException(ex); } } diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java index cda9b5dde84..f4c1e574041 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java @@ -119,8 +119,8 @@ public abstract class AbstractHttpClientMockTests { try { HttpEntity entity = mock(HttpEntity.class); given(entity.getContent()).willReturn(new ByteArrayInputStream(content)); - Header contentTypeHeader = contentType != null - ? new BasicHeader("Content-Type", contentType) : null; + Header contentTypeHeader = (contentType != null + ? new BasicHeader("Content-Type", contentType) : null); given(entity.getContentType()).willReturn(contentTypeHeader); given(response.getEntity()).willReturn(entity); return entity; @@ -138,7 +138,7 @@ public abstract class AbstractHttpClientMockTests { protected void mockHttpHeader(CloseableHttpResponse response, String headerName, String value) { - Header header = value != null ? new BasicHeader(headerName, value) : null; + Header header = (value != null ? new BasicHeader(headerName, value) : null); given(response.getFirstHeader(headerName)).willReturn(header); } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java index 4f9bf4502b0..c5bf6696170 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java @@ -85,8 +85,8 @@ public class RemoteDevToolsAutoConfiguration { public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() { Handler handler = new HttpStatusHandler(); return new UrlHandlerMapper( - (this.serverProperties.getServlet().getContextPath() == null ? "" - : this.serverProperties.getServlet().getContextPath()) + (this.serverProperties.getServlet().getContextPath() != null + ? this.serverProperties.getServlet().getContextPath() : "") + this.properties.getRemote().getContextPath(), handler); } @@ -127,8 +127,8 @@ public class RemoteDevToolsAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "remoteRestartHandlerMapper") public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) { - String url = (this.serverProperties.getServlet().getContextPath() == null ? "" - : this.serverProperties.getServlet().getContextPath()) + String url = (this.serverProperties.getServlet().getContextPath() != null + ? this.serverProperties.getServlet().getContextPath() : "") + this.properties.getRemote().getContextPath() + "/restart"; logger.warn("Listening for remote restart updates on " + url); Handler handler = new HttpRestartServerHandler(server); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java index 0cc367215d7..174f050a64e 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java @@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { File home = getHomeFolder(); - File propertyFile = (home == null ? null : new File(home, FILE_NAME)); + File propertyFile = (home != null ? new File(home, FILE_NAME) : null); if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) { FileSystemResource resource = new FileSystemResource(propertyFile); Properties properties; diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java index c057704202d..6ae40514b09 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java @@ -133,7 +133,7 @@ public class ClassPathChangeUploader private void logUpload(ClassLoaderFiles classLoaderFiles) { int size = classLoaderFiles.size(); logger.info( - "Uploaded " + size + " class " + (size == 1 ? "resource" : "resources")); + "Uploaded " + size + " class " + (size != 1 ? "resources" : "resource")); } private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException { @@ -160,10 +160,10 @@ public class ClassPathChangeUploader private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile) throws IOException { ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType()); - byte[] bytes = (kind == Kind.DELETED ? null - : FileCopyUtils.copyToByteArray(changedFile.getFile())); - long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis() - : changedFile.getFile().lastModified()); + byte[] bytes = (kind != Kind.DELETED + ? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null); + long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified() + : System.currentTimeMillis()); return new ClassLoaderFile(kind, lastModified, bytes); } diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java index 101f4d66a94..278538065dd 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java @@ -55,7 +55,7 @@ public class ClassLoaderFile implements Serializable { */ public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) { Assert.notNull(kind, "Kind must not be null"); - Assert.isTrue(kind == Kind.DELETED ? contents == null : contents != null, + Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null, () -> "Contents must " + (kind == Kind.DELETED ? "" : "not ") + "be null"); this.kind = kind; diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java index 6ce3d3a1435..121adb0c438 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java @@ -88,8 +88,8 @@ public class HttpTunnelConnection implements TunnelConnection { throw new IllegalArgumentException("Malformed URL '" + url + "'"); } this.requestFactory = requestFactory; - this.executor = (executor == null - ? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor); + this.executor = (executor != null ? executor + : Executors.newCachedThreadPool(new TunnelThreadFactory())); } @Override diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java index b8596014d24..ee3b92b7778 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java @@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests { private void assertClassFile(ClassLoaderFile file, String content, Kind kind) { assertThat(file.getContents()) - .isEqualTo(content == null ? null : content.getBytes()); + .isEqualTo(content != null ? content.getBytes() : null); assertThat(file.getKind()).isEqualTo(kind); } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java index 8abb2323aa3..ce0e2900fd8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java @@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample { ObjectProvider builderProvider, Environment environment) { RestTemplateBuilder builder = builderProvider.getIfAvailable(); - TestRestTemplate template = builder == null ? new TestRestTemplate() - : new TestRestTemplate(builder); + TestRestTemplate template = (builder != null ? new TestRestTemplate(builder) + : new TestRestTemplate()); template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment)); return template; } diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java index c0d85b76c31..83ccb64d325 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java @@ -31,6 +31,7 @@ import org.springframework.test.context.junit4.SpringRunner; * * @author Stephane Nicoll */ +@SuppressWarnings("unused") // tag::test[] @RunWith(SpringRunner.class) @SpringBootTest(properties = "spring.jmx.enabled=true") @@ -43,7 +44,6 @@ public class SampleJmxTests { @Test public void exampleTest() { // ... - } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 4160bdd3f89..81f45d838b2 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java @@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource } Annotation mergedAnnotation = AnnotatedElementUtils.getMergedAnnotation(source, annotationType); - return mergedAnnotation != null ? mergedAnnotation - : findMergedAnnotation(source.getSuperclass(), annotationType); + return (mergedAnnotation != null ? mergedAnnotation + : findMergedAnnotation(source.getSuperclass(), annotationType)); } private void collectProperties(Annotation annotation, Method attribute, @@ -143,8 +143,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource private String getName(PropertyMapping typeMapping, PropertyMapping attributeMapping, Method attribute) { - String prefix = (typeMapping == null ? "" : typeMapping.value()); - String name = (attributeMapping == null ? "" : attributeMapping.value()); + String prefix = (typeMapping != null ? typeMapping.value() : ""); + String name = (attributeMapping != null ? attributeMapping.value() : ""); if (!StringUtils.hasText(name)) { name = toKebabCase(attribute.getName()); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index cce4c141b7a..e5c48656d4b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java @@ -115,10 +115,10 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { private String getAnnotationsDescription(Set> annotations) { StringBuilder result = new StringBuilder(); for (Class annotation : annotations) { - result.append(result.length() == 0 ? "" : ", "); + result.append(result.length() != 0 ? ", " : ""); result.append("@" + ClassUtils.getShortName(annotation)); } - result.insert(0, annotations.size() == 1 ? "annotation " : "annotations "); + result.insert(0, annotations.size() != 1 ? "annotations " : "annotation "); return result.toString(); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index 932560de506..198528973e7 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -168,10 +168,10 @@ class ImportsContextCustomizer implements ContextCustomizer { public String[] selectImports(AnnotationMetadata importingClassMetadata) { BeanDefinition definition = this.beanFactory .getBeanDefinition(ImportsConfiguration.BEAN_NAME); - Object testClass = (definition == null ? null - : definition.getAttribute(TEST_CLASS_ATTRIBUTE)); - return (testClass == null ? NO_IMPORTS - : new String[] { ((Class) testClass).getName() }); + Object testClass = (definition != null + ? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null); + return (testClass != null ? new String[] { ((Class) testClass).getName() } + : NO_IMPORTS); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java index 4dc439dfa97..54f07aaa493 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java @@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder { private String getParentPackage(String sourcePackage) { int lastDot = sourcePackage.lastIndexOf('.'); - return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot)); + return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : ""); } /** diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java index fd9aaeece35..d320b31b1ac 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java @@ -44,6 +44,7 @@ import org.springframework.core.annotation.Order; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; import org.springframework.test.context.ContextConfigurationAttributes; import org.springframework.test.context.ContextCustomizer; import org.springframework.test.context.ContextLoader; @@ -109,11 +110,11 @@ public class SpringBootContextLoader extends AbstractContextLoader { if (!ObjectUtils.isEmpty(config.getActiveProfiles())) { setActiveProfiles(environment, config.getActiveProfiles()); } + ResourceLoader resourceLoader = (application.getResourceLoader() != null + ? application.getResourceLoader() + : new DefaultResourceLoader(getClass().getClassLoader())); TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, - application.getResourceLoader() == null - ? new DefaultResourceLoader(getClass().getClassLoader()) - : application.getResourceLoader(), - config.getPropertySourceLocations()); + resourceLoader, config.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, getInlinedProperties(config)); application.setEnvironment(environment); diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index b0832ec6251..d2e00ff24f7 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -164,8 +164,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr WebAppConfiguration webAppConfiguration = AnnotatedElementUtils .findMergedAnnotation(mergedConfig.getTestClass(), WebAppConfiguration.class); - String resourceBasePath = (webAppConfiguration == null ? "src/main/webapp" - : webAppConfiguration.value()); + String resourceBasePath = (webAppConfiguration != null + ? webAppConfiguration.value() : "src/main/webapp"); mergedConfig = new WebMergedContextConfiguration(mergedConfig, resourceBasePath); } @@ -313,17 +313,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr */ protected WebEnvironment getWebEnvironment(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.webEnvironment()); + return (annotation != null ? annotation.webEnvironment() : null); } protected Class[] getClasses(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.classes()); + return (annotation != null ? annotation.classes() : null); } protected String[] getProperties(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.properties()); + return (annotation != null ? annotation.properties() : null); } protected SpringBootTest getAnnotation(Class testClass) { diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java index 4e92f8a1823..798fffc80aa 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java @@ -75,7 +75,7 @@ public final class JsonContent implements AssertProvider { @Override public String toString() { return "JsonContent " + this.json - + (this.type == null ? "" : " created from " + this.type); + + (this.type != null ? " created from " + this.type : ""); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java index e26d875011d..8e25f6ffca2 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java @@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert resourceLoadClass, Charset charset) { this.resourceLoadClass = resourceLoadClass; - this.charset = charset == null ? StandardCharsets.UTF_8 : charset; + this.charset = (charset != null ? charset : StandardCharsets.UTF_8); } Class getResourceLoadClass() { diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java index 71c3b63aa2a..1dc778fff63 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java @@ -63,7 +63,7 @@ public final class ObjectContent implements AssertProvider { while (prefix != null && prefix.endsWith(".")) { prefix = prefix.substring(0, prefix.length() - 1); } - StringBuilder fullName = new StringBuilder(prefix == null ? "" : prefix); + StringBuilder fullName = new StringBuilder(prefix != null ? prefix : ""); if (fullName.length() > 0 && name != null) { fullName.append("."); } - fullName.append(name == null ? "" : ConfigurationMetadata.toDashedCase(name)); + fullName.append(name != null ? ConfigurationMetadata.toDashedCase(name) : ""); return fullName.toString(); } @@ -196,7 +196,7 @@ public final class ItemMetadata implements Comparable { } private int nullSafeHashCode(Object o) { - return (o == null ? 0 : o.hashCode()); + return (o != null ? o.hashCode() : 0); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestConfigurationMetadataAnnotationProcessor.java index b02abd1da5e..43fe564c4e2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/TestConfigurationMetadataAnnotationProcessor.java @@ -98,8 +98,8 @@ public class TestConfigurationMetadataAnnotationProcessor } return this.metadata; } - catch (IOException e) { - throw new RuntimeException("Failed to read metadata from disk", e); + catch (IOException ex) { + throw new RuntimeException("Failed to read metadata from disk", ex); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java index 4b1a389e928..d4242f3694f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java @@ -109,8 +109,8 @@ public class DefaultLaunchScript implements LaunchScript { } } else { - value = (defaultValue == null ? matcher.group(0) - : defaultValue.substring(1)); + value = (defaultValue != null ? defaultValue.substring(1) + : matcher.group(0)); } matcher.appendReplacement(expanded, value.replace("$", "\\$")); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java index 79cb32b7891..f6ae4c48ea4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java @@ -356,7 +356,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { @Override public int read() throws IOException { - int read = (this.headerStream == null ? -1 : this.headerStream.read()); + int read = (this.headerStream != null ? this.headerStream.read() : -1); if (read != -1) { this.headerStream = null; return read; @@ -371,8 +371,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { @Override public int read(byte[] b, int off, int len) throws IOException { - int read = (this.headerStream == null ? -1 - : this.headerStream.read(b, off, len)); + int read = (this.headerStream != null ? this.headerStream.read(b, off, len) + : -1); if (read != -1) { this.headerStream = null; return read; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java index 245c1e05b64..e9fbd2a6328 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java @@ -63,7 +63,7 @@ public class Library { * @param unpackRequired if the library needs to be unpacked before it can be used */ public Library(String name, File file, LibraryScope scope, boolean unpackRequired) { - this.name = (name == null ? file.getName() : name); + this.name = (name != null ? name : file.getName()); this.file = file; this.scope = scope; this.unpackRequired = unpackRequired; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index 9854cd86bcd..42849146491 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -452,8 +452,8 @@ public abstract class MainClassFinder { "Unable to find a single main class from the following candidates " + matchingMainClasses); } - return matchingMainClasses.isEmpty() ? null - : matchingMainClasses.iterator().next().getName(); + return (matchingMainClasses.isEmpty() ? null + : matchingMainClasses.iterator().next().getName()); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index 9d7448017cc..6b265e4aaa9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java @@ -116,8 +116,8 @@ public abstract class Launcher { protected final Archive createArchive() throws Exception { ProtectionDomain protectionDomain = getClass().getProtectionDomain(); CodeSource codeSource = protectionDomain.getCodeSource(); - URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); - String path = (location == null ? null : location.getSchemeSpecificPart()); + URI location = (codeSource != null ? codeSource.getLocation().toURI() : null); + String path = (location != null ? location.getSchemeSpecificPart() : null); if (path == null) { throw new IllegalStateException("Unable to determine code source archive"); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java index 83a2ba526b3..9ef7a245e06 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java @@ -38,7 +38,7 @@ public class MainMethodRunner { */ public MainMethodRunner(String mainClass, String[] args) { this.mainClassName = mainClass; - this.args = (args == null ? null : args.clone()); + this.args = (args != null ? args.clone() : null); } public void run() throws Exception { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 9f95a260a77..2b89514879c 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -434,8 +434,9 @@ public class PropertiesLauncher extends Launcher { return SystemPropertyUtils.resolvePlaceholders(this.properties, value); } } - return defaultValue == null ? defaultValue - : SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue); + return (defaultValue != null + ? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue) + : defaultValue); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index 1adc4f6afe6..76dac5420de 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -127,8 +127,7 @@ public class RandomAccessDataFile implements RandomAccessData { } /** - * {@link InputStream} implementation for the - * {@link RandomAccessDataFile}. + * {@link InputStream} implementation for the {@link RandomAccessDataFile}. */ private class DataInputStream extends InputStream { @@ -145,7 +144,7 @@ public class RandomAccessDataFile implements RandomAccessData { @Override public int read(byte[] b) throws IOException { - return read(b, 0, b == null ? 0 : b.length); + return read(b, 0, b != null ? b.length : 0); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java index f3b36f6111b..22576ad9d0b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java @@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler { } private int hashCode(String protocol, String file) { - int result = (protocol == null ? 0 : protocol.hashCode()); + int result = (protocol != null ? protocol.hashCode() : 0); int separatorIndex = file.indexOf(SEPARATOR); if (separatorIndex == -1) { return result + file.hashCode(); @@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler { String path = name.substring(FILE_PROTOCOL.length()); File file = new File(URLDecoder.decode(path, "UTF-8")); Map cache = rootFileCache.get(); - JarFile result = (cache == null ? null : cache.get(file)); + JarFile result = (cache != null ? cache.get(file) : null); if (result == null) { result = new JarFile(file); addToRootFileCache(file, result); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java index b5c76e907ec..a6188eeed60 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java @@ -77,7 +77,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader { @Override public Attributes getAttributes() throws IOException { Manifest manifest = this.jarFile.getManifest(); - return (manifest == null ? null : manifest.getAttributes(getName())); + return (manifest != null ? manifest.getAttributes(getName()) : null); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index b0d32429a92..5d7fe68c736 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -168,7 +168,7 @@ public class JarFile extends java.util.jar.JarFile { @Override public Manifest getManifest() throws IOException { - Manifest manifest = (this.manifest == null ? null : this.manifest.get()); + Manifest manifest = (this.manifest != null ? this.manifest.get() : null); if (manifest == null) { try { manifest = this.manifestSupplier.get(); @@ -222,7 +222,7 @@ public class JarFile extends java.util.jar.JarFile { if (ze instanceof JarEntry) { return this.entries.getInputStream((JarEntry) ze); } - return getInputStream(ze == null ? null : ze.getName()); + return getInputStream(ze != null ? ze.getName() : null); } InputStream getInputStream(String name) throws IOException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index dc24840afe4..67a4fa3cf09 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -277,7 +277,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { } private AsciiBytes applyFilter(AsciiBytes name) { - return (this.filter == null ? name : this.filter.apply(name)); + return (this.filter != null ? this.filter.apply(name) : name); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 46d8b9e2965..52b5e1487c3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -204,7 +204,7 @@ final class JarURLConnection extends java.net.JarURLConnection { return this.jarFile.size(); } JarEntry entry = getJarEntry(); - return (entry == null ? -1 : (int) entry.getSize()); + return (entry != null ? (int) entry.getSize() : -1); } catch (IOException ex) { return -1; @@ -219,7 +219,7 @@ final class JarURLConnection extends java.net.JarURLConnection { @Override public String getContentType() { - return (this.jarEntryName == null ? null : this.jarEntryName.getContentType()); + return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null); } @Override @@ -241,7 +241,7 @@ final class JarURLConnection extends java.net.JarURLConnection { } try { JarEntry entry = getJarEntry(); - return (entry == null ? 0 : entry.getTime()); + return (entry != null ? entry.getTime() : 0); } catch (IOException ex) { return 0; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index f76ed84dfd0..0b9d0bfdb9f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java @@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils { if (propVal != null) { return propVal; } - return properties == null ? null : properties.getProperty(placeholderName); + return (properties != null ? properties.getProperty(placeholderName) : null); } public static String getProperty(String key) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java index 5a2b83dbadd..86bcce96ec5 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java @@ -69,9 +69,9 @@ public class ExplodedArchiveTests { File file = this.temporaryFolder.newFile(); TestJarCreator.createTestJar(file); - this.rootFolder = StringUtils.hasText(folderName) + this.rootFolder = (StringUtils.hasText(folderName) ? this.temporaryFolder.newFolder(folderName) - : this.temporaryFolder.newFolder(); + : this.temporaryFolder.newFolder()); JarFile jarFile = new JarFile(file); Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 3ec06db410b..b46b0ef3441 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -401,8 +401,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { private void addDependencies(List urls) throws MalformedURLException, MojoExecutionException { - FilterArtifacts filters = this.useTestClasspath ? getFilters() - : getFilters(new TestArtifactFilter()); + FilterArtifacts filters = (this.useTestClasspath ? getFilters() + : getFilters(new TestArtifactFilter())); Set artifacts = filterDependencies(this.project.getArtifacts(), filters); for (Artifact artifact : artifacts) { @@ -450,7 +450,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { public void uncaughtException(Thread thread, Throwable ex) { if (!(ex instanceof ThreadDeath)) { synchronized (this.monitor) { - this.exception = (this.exception == null ? ex : this.exception); + this.exception = (this.exception != null ? this.exception : ex); } getLog().warn(ex); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index a7490f28c92..f0cb6c65b3c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -144,8 +144,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { /** * A list of the libraries that must be unpacked from fat jars in order to run. - * Specify each library as a {@code } with a {@code } and - * a {@code } and they will be unpacked at runtime. + * Specify each library as a {@code } with a {@code } and a + * {@code } and they will be unpacked at runtime. * @since 1.1 */ @Parameter @@ -156,10 +156,10 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { * jar. *

* Currently, some tools do not accept this format so you may not always be able to - * use this technique. For example, {@code jar -xf} may silently fail to extract - * a jar or war that has been made fully-executable. It is recommended that you only - * enable this option if you intend to execute it directly, rather than running it - * with {@code java -jar} or deploying it to a servlet container. + * use this technique. For example, {@code jar -xf} may silently fail to extract a jar + * or war that has been made fully-executable. It is recommended that you only enable + * this option if you intend to execute it directly, rather than running it with + * {@code java -jar} or deploying it to a servlet container. * @since 1.3 */ @Parameter(defaultValue = "false") @@ -226,7 +226,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { } private File getTargetFile() { - String classifier = (this.classifier == null ? "" : this.classifier.trim()); + String classifier = (this.classifier != null ? this.classifier.trim() : ""); if (!classifier.isEmpty() && !classifier.startsWith("-")) { classifier = "-" + classifier; } @@ -287,7 +287,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { } private String removeLineBreaks(String description) { - return (description == null ? null : description.replaceAll("\\s+", " ")); + return (description != null ? description.replaceAll("\\s+", " ") : null); } private void putIfMissing(Properties properties, String key, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java index 2cbf74f3a3d..8ea84f92f68 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java @@ -62,7 +62,7 @@ public class DefaultApplicationArguments implements ApplicationArguments { @Override public List getOptionValues(String name) { List values = this.source.getOptionValues(name); - return (values == null ? null : Collections.unmodifiableList(values)); + return (values != null ? Collections.unmodifiableList(values) : null); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java index ab9ad2a93bb..4f317e4ab3f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java @@ -93,7 +93,7 @@ class ExitCodeGenerators implements Iterable { } } catch (Exception ex) { - exitCode = (exitCode == 0 ? 1 : exitCode); + exitCode = (exitCode != 0 ? exitCode : 1); ex.printStackTrace(); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java index 703bb00a8a0..a22ee6b6e38 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java @@ -107,8 +107,8 @@ public class ResourceBanner implements Banner { } protected String getApplicationVersion(Class sourceClass) { - Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); - return (sourcePackage == null ? null : sourcePackage.getImplementationVersion()); + Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null); + return (sourcePackage != null ? sourcePackage.getImplementationVersion() : null); } protected String getBootVersion() { @@ -132,14 +132,14 @@ public class ResourceBanner implements Banner { MutablePropertySources sources = new MutablePropertySources(); String applicationTitle = getApplicationTitle(sourceClass); Map titleMap = Collections.singletonMap("application.title", - (applicationTitle == null ? "" : applicationTitle)); + (applicationTitle != null ? applicationTitle : "")); sources.addFirst(new MapPropertySource("title", titleMap)); return new PropertySourcesPropertyResolver(sources); } protected String getApplicationTitle(Class sourceClass) { - Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); - return (sourcePackage == null ? null : sourcePackage.getImplementationTitle()); + Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null); + return (sourcePackage != null ? sourcePackage.getImplementationTitle() : null); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 755d98c4d7f..16c8c0fc0da 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -553,8 +553,8 @@ public class SpringApplication { if (this.bannerMode == Banner.Mode.OFF) { return null; } - ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader - : new DefaultResourceLoader(getClassLoader()); + ResourceLoader resourceLoader = (this.resourceLoader != null ? this.resourceLoader + : new DefaultResourceLoader(getClassLoader())); SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter( resourceLoader, this.banner); if (this.bannerMode == Mode.LOG) { @@ -1304,7 +1304,7 @@ public class SpringApplication { } catch (Exception ex) { ex.printStackTrace(); - exitCode = (exitCode == 0 ? 1 : exitCode); + exitCode = (exitCode != 0 ? exitCode : 1); } return exitCode; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java index 7bd4fb6c3e1..947fc2f28bc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java @@ -163,7 +163,7 @@ class SpringApplicationBannerPrinter { @Override public void printBanner(Environment environment, Class sourceClass, PrintStream out) { - sourceClass = (sourceClass == null ? this.sourceClass : sourceClass); + sourceClass = (sourceClass != null ? sourceClass : this.sourceClass); this.banner.printBanner(environment, sourceClass, out); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java index 233f1d0983e..16c94e87fe8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java @@ -99,7 +99,7 @@ class SpringApplicationRunListeners { } else { String message = ex.getMessage(); - message = (message == null ? "no error message" : message); + message = (message != null ? message : "no error message"); this.log.warn("Error handling failed (" + message + ")"); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java index 8b144e2b791..99e60aceed4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java @@ -49,7 +49,7 @@ class SpringBootBanner implements Banner { printStream.println(line); } String version = SpringBootVersion.getVersion(); - version = (version == null ? "" : " (v" + version + ")"); + version = (version != null ? " (v" + version + ")" : ""); StringBuilder padding = new StringBuilder(); while (padding.length() < STRAP_LINE_SIZE - (version.length() + SPRING_BOOT.length())) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index 87510564bef..f3164e2ea7e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -117,8 +117,8 @@ class StartupInfoLogger { String startedBy = getValue("started by ", () -> System.getProperty("user.name")); String in = getValue("in ", () -> System.getProperty("user.dir")); ApplicationHome home = new ApplicationHome(this.sourceClass); - String path = (home.getSource() == null ? "" - : home.getSource().getAbsolutePath()); + String path = (home.getSource() != null ? home.getSource().getAbsolutePath() + : ""); if (startedBy == null && path == null) { return ""; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java index 6f6d7080c57..9f5868fc978 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java @@ -94,7 +94,7 @@ public final class AnsiColors { private final double b; LabColor(Integer rgb) { - this(rgb == null ? null : new Color(rgb)); + this(rgb != null ? new Color(rgb) : null); } LabColor(Color color) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index 13ab654c416..d75af0fd092 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -408,7 +408,7 @@ public class SpringApplicationBuilder { for (String candidate : candidates) { int candidateIndex = property.indexOf(candidate); if (candidateIndex > 0) { - index = (index == -1 ? candidateIndex : Math.min(index, candidateIndex)); + index = (index != -1 ? Math.min(index, candidateIndex) : candidateIndex); } } return index; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index 200fad0c620..5a7afea4aa6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -223,7 +223,7 @@ public class CloudFoundryVcapEnvironmentPostProcessor properties.put(name, value.toString()); } else { - properties.put(name, value == null ? "" : value); + properties.put(name, value != null ? value : ""); } }); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java index 6df48993012..03bff0b9de0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java @@ -163,7 +163,7 @@ public class ApplicationPidFileWriter private boolean failOnWriteError(SpringApplicationEvent event) { String value = getProperty(event, FAIL_ON_WRITE_ERROR_PROPERTIES); - return (value == null ? false : Boolean.parseBoolean(value)); + return (value != null ? Boolean.parseBoolean(value) : false); } private String getProperty(SpringApplicationEvent event, List candidates) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java index f27a3c2d75a..4987b4bccd9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java @@ -77,7 +77,7 @@ public class ConfigurationBeanFactoryMetadata implements BeanFactoryPostProcesso public A findFactoryAnnotation(String beanName, Class type) { Method method = findFactoryMethod(beanName); - return (method == null ? null : AnnotationUtils.findAnnotation(method, type)); + return (method != null ? AnnotationUtils.findAnnotation(method, type) : null); } public Method findFactoryMethod(String beanName) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java index 14343532f4c..bbdad56c6f0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java @@ -61,7 +61,7 @@ final class FailureAnalyzers implements SpringBootExceptionReporter { FailureAnalyzers(ConfigurableApplicationContext context, ClassLoader classLoader) { Assert.notNull(context, "Context must not be null"); - this.classLoader = (classLoader == null ? context.getClassLoader() : classLoader); + this.classLoader = (classLoader != null ? classLoader : context.getClassLoader()); this.analyzers = loadFailureAnalyzers(this.classLoader); prepareFailureAnalyzers(this.analyzers, context); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java index 4b189f0c2d5..424d1300f1c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java @@ -57,7 +57,7 @@ class BeanCurrentlyInCreationFailureAnalyzer if (index == -1) { beansInCycle.add(beanInCycle); } - cycleStart = (cycleStart == -1 ? index : cycleStart); + cycleStart = (cycleStart != -1 ? cycleStart : index); } candidate = candidate.getCause(); } @@ -82,7 +82,7 @@ class BeanCurrentlyInCreationFailureAnalyzer String leftSide = (i < cycleStart ? " " : "↑"); message.append(String.format("%s ↓%n", leftSide)); } - String leftSide = i < cycleStart ? " " : "|"; + String leftSide = (i < cycleStart ? " " : "|"); message.append(String.format("%s %s%n", leftSide, beanInCycle)); } message.append(String.format("└─────┘%n")); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java index 3cb9c47c57c..afff3dc634c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java @@ -126,7 +126,7 @@ public class SpringApplicationJsonEnvironmentPostProcessor private void flatten(String prefix, Map result, Map map) { - String namePrefix = (prefix == null ? "" : prefix + "."); + String namePrefix = (prefix != null ? prefix + "." : ""); map.forEach((key, value) -> extract(namePrefix + key, result, value)); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java index 57428b5fe04..6bd415c1941 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java @@ -42,8 +42,9 @@ public class CompositeDataSourcePoolMetadataProvider */ public CompositeDataSourcePoolMetadataProvider( Collection providers) { - this.providers = (providers == null ? Collections.emptyList() - : Collections.unmodifiableList(new ArrayList<>(providers))); + this.providers = (providers != null + ? Collections.unmodifiableList(new ArrayList<>(providers)) + : Collections.emptyList()); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java index f4b64408c97..65257b96b9c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java @@ -35,7 +35,7 @@ public class TomcatDataSourcePoolMetadata @Override public Integer getActive() { ConnectionPool pool = getDataSource().getPool(); - return (pool == null ? 0 : pool.getActive()); + return (pool != null ? pool.getActive() : 0); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java index d89f8034223..7903d91706e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java @@ -99,7 +99,7 @@ public class AtomikosDependsOnBeanFactoryPostProcessor } private List asList(String[] array) { - return (array == null ? Collections.emptyList() : Arrays.asList(array)); + return (array != null ? Arrays.asList(array) : Collections.emptyList()); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/DataSourceXAResourceRecoveryHelper.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/DataSourceXAResourceRecoveryHelper.java index d3def230ef1..19cc14b9cfe 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/DataSourceXAResourceRecoveryHelper.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/narayana/DataSourceXAResourceRecoveryHelper.java @@ -127,8 +127,8 @@ public class DataSourceXAResourceRecoveryHelper try { this.xaConnection.close(); } - catch (SQLException e) { - logger.warn("Failed to close connection", e); + catch (SQLException ex) { + logger.warn("Failed to close connection", ex); } finally { this.xaConnection = null; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java index 3d7ef319e65..28fae9b136e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java @@ -65,7 +65,7 @@ public class SimpleFormatter extends Formatter { private String getThreadName() { String name = Thread.currentThread().getName(); - return (name == null ? "" : name); + return (name != null ? name : ""); } private static String getOrUseDefault(String key, String defaultValue) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 15176f2986b..6bb5d716430 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -101,7 +101,7 @@ public final class ColorConverter extends LogEventPatternConverter { } PatternParser parser = PatternLayout.createPatternParser(config); List formatters = parser.parse(options[0]); - AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1])); + AnsiElement element = (options.length != 1 ? ELEMENTS.get(options[1]) : null); return new ColorConverter(formatters, element); } @@ -126,7 +126,7 @@ public final class ColorConverter extends LogEventPatternConverter { if (element == null) { // Assume highlighting element = LEVELS.get(event.getLevel().intLevel()); - element = (element == null ? AnsiColor.GREEN : element); + element = (element != null ? element : AnsiColor.GREEN); } appendAnsiString(toAppendTo, buf.toString(), element); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java index a73c2f57b1f..31fc33ec8a8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java @@ -67,7 +67,7 @@ public class ColorConverter extends CompositeConverter { if (element == null) { // Assume highlighting element = LEVELS.get(event.getLevel().toInteger()); - element = (element == null ? AnsiColor.GREEN : element); + element = (element != null ? element : AnsiColor.GREEN); } return toAnsiString(in, element); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java index 216c78e772c..241cf6d0b0d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java @@ -57,7 +57,7 @@ public class ApplicationHome { * @param sourceClass the source class or {@code null} */ public ApplicationHome(Class sourceClass) { - this.source = findSource(sourceClass == null ? getStartClass() : sourceClass); + this.source = findSource(sourceClass != null ? sourceClass : getStartClass()); this.dir = findHomeDir(this.source); } @@ -88,11 +88,11 @@ public class ApplicationHome { private File findSource(Class sourceClass) { try { - ProtectionDomain domain = (sourceClass == null ? null - : sourceClass.getProtectionDomain()); - CodeSource codeSource = (domain == null ? null : domain.getCodeSource()); - URL location = (codeSource == null ? null : codeSource.getLocation()); - File source = (location == null ? null : findSource(location)); + ProtectionDomain domain = (sourceClass != null + ? sourceClass.getProtectionDomain() : null); + CodeSource codeSource = (domain != null ? domain.getCodeSource() : null); + URL location = (codeSource != null ? codeSource.getLocation() : null); + File source = (location != null ? findSource(location) : null); if (source != null && source.exists() && !isUnitTest()) { return source.getAbsoluteFile(); } @@ -136,7 +136,7 @@ public class ApplicationHome { private File findHomeDir(File source) { File homeDir = source; - homeDir = (homeDir == null ? findDefaultHomeDir() : homeDir); + homeDir = (homeDir != null ? homeDir : findDefaultHomeDir()); if (homeDir.isFile()) { homeDir = homeDir.getParentFile(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index 765e430cf7c..048ecc1512a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -62,7 +62,7 @@ public class ApplicationPid { @Override public String toString() { - return (this.pid == null ? "???" : this.pid); + return (this.pid != null ? this.pid : "???"); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index 8e39f343499..c239e5ba3f7 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -607,13 +607,13 @@ public class RestTemplateBuilder { } private Set append(Set set, T addition) { - Set result = new LinkedHashSet<>(set == null ? Collections.emptySet() : set); + Set result = new LinkedHashSet<>(set != null ? set : Collections.emptySet()); result.add(addition); return Collections.unmodifiableSet(result); } private Set append(Set set, Collection additions) { - Set result = new LinkedHashSet<>(set == null ? Collections.emptySet() : set); + Set result = new LinkedHashSet<>(set != null ? set : Collections.emptySet()); result.addAll(additions); return Collections.unmodifiableSet(result); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java index 0f36e3a8b2c..6c097fc6c45 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java @@ -172,7 +172,7 @@ public class JettyWebServer implements WebServer { private String getActualPortsDescription() { StringBuilder ports = new StringBuilder(); for (Connector connector : this.server.getConnectors()) { - ports.append(ports.length() == 0 ? "" : ", "); + ports.append(ports.length() != 0 ? ", " : ""); ports.append(getLocalPort(connector) + getProtocols(connector)); } return ports.toString(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java index 71a2a51d650..85827cad094 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java @@ -65,7 +65,7 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { Class result = findExistingLoadedClass(name); - result = (result == null ? doLoadClass(name) : result); + result = (result != null ? result : doLoadClass(name)); if (result == null) { throw new ClassNotFoundException(name); } @@ -75,7 +75,7 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { private Class findExistingLoadedClass(String name) { Class resultClass = findLoadedClass0(name); - resultClass = (resultClass == null ? findLoadedClass(name) : resultClass); + resultClass = (resultClass != null ? resultClass : findLoadedClass(name)); return resultClass; } @@ -83,10 +83,10 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { checkPackageAccess(name); if ((this.delegate || filter(name, true))) { Class result = loadFromParent(name); - return (result == null ? findClassIgnoringNotFound(name) : result); + return (result != null ? result : findClassIgnoringNotFound(name)); } Class result = findClassIgnoringNotFound(name); - return (result == null ? loadFromParent(name) : result); + return (result != null ? result : loadFromParent(name)); } private Class resolveIfNecessary(Class resultClass, boolean resolve) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index bd14a7646ae..e3e824d109a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -319,7 +319,7 @@ public class TomcatWebServer implements WebServer { private String getPortsDescription(boolean localPort) { StringBuilder ports = new StringBuilder(); for (Connector connector : this.tomcat.getService().findConnectors()) { - ports.append(ports.length() == 0 ? "" : " "); + ports.append(ports.length() != 0 ? " " : ""); int port = (localPort ? connector.getLocalPort() : connector.getPort()); ports.append(port + " (" + connector.getScheme() + ")"); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java index a39c70035de..1497c6c086c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java @@ -255,8 +255,8 @@ public class UndertowServletWebServer implements WebServer { private Port getPortFromChannel(BoundChannel channel) { SocketAddress socketAddress = channel.getLocalAddress(); if (socketAddress instanceof InetSocketAddress) { - String protocol = ReflectionUtils.findField(channel.getClass(), "ssl") != null - ? "https" : "http"; + String protocol = (ReflectionUtils.findField(channel.getClass(), + "ssl") != null ? "https" : "http"); return new Port(((InetSocketAddress) socketAddress).getPort(), protocol); } return null; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 604090f81c5..dcd0e22dc21 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -303,8 +303,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac AccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver( createWorker(), this.accessLogDirectory, prefix, this.accessLogSuffix, this.accessLogRotate); - String formatString = (this.accessLogPattern != null) ? this.accessLogPattern - : "common"; + String formatString = (this.accessLogPattern != null ? this.accessLogPattern + : "common"); return new AccessLogHandler(handler, accessLogReceiver, formatString, Undertow.class.getClassLoader()); } @@ -355,8 +355,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac List metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources(); List resourceJarUrls = new ArrayList<>(); List resourceManagers = new ArrayList<>(); - ResourceManager rootResourceManager = docBase.isDirectory() - ? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase); + ResourceManager rootResourceManager = (docBase.isDirectory() + ? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase)); resourceManagers.add(root == null ? rootResourceManager : new LoaderHidingResourceManager(rootResourceManager)); for (URL url : metaInfResourceUrls) { @@ -389,8 +389,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac File root = docBase != null ? docBase : createTempDir("undertow-docbase"); return root.getCanonicalFile(); } - catch (IOException e) { - throw new IllegalStateException("Cannot get canonical document root", e); + catch (IOException ex) { + throw new IllegalStateException("Cannot get canonical document root", ex); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java index 6590e69c8bd..9096fd36b94 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java @@ -84,7 +84,7 @@ public class ErrorPage { * @return the status value (or 0 for a page that matches any status) */ public int getStatusCode() { - return (this.status == null ? 0 : this.status.value()); + return (this.status != null ? this.status.value() : 0); } /** @@ -92,7 +92,7 @@ public class ErrorPage { * @return the exception type name (or {@code null} if there is none) */ public String getExceptionName() { - return (this.exception == null ? null : this.exception.getName()); + return (this.exception != null ? this.exception.getName() : null); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index 35c0403c317..cf6a778b387 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -279,7 +279,7 @@ public final class MimeMappings implements Iterable { */ public String add(String extension, String mimeType) { Mapping previous = this.map.put(extension, new Mapping(extension, mimeType)); - return (previous == null ? null : previous.getMimeType()); + return (previous != null ? previous.getMimeType() : null); } /** @@ -289,7 +289,7 @@ public final class MimeMappings implements Iterable { */ public String get(String extension) { Mapping mapping = this.map.get(extension); - return (mapping == null ? null : mapping.getMimeType()); + return (mapping != null ? mapping.getMimeType() : null); } /** @@ -299,7 +299,7 @@ public final class MimeMappings implements Iterable { */ public String remove(String extension) { Mapping previous = this.map.remove(extension); - return (previous == null ? null : previous.getMimeType()); + return (previous != null ? previous.getMimeType() : null); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 02396c273c4..acc092b7fb9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -270,7 +270,7 @@ public class ServletContextInitializerBeans @Override public RegistrationBean createRegistrationBean(String name, Servlet source, int totalNumberOfSourceBeans) { - String url = (totalNumberOfSourceBeans == 1 ? "/" : "/" + name + "/"); + String url = (totalNumberOfSourceBeans != 1 ? "/" + name + "/" : "/"); if (name.equals(DISPATCHER_SERVLET_NAME)) { url = "/"; // always map the main dispatcherServlet to "/" } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java index cd070d25f67..a0671f66bd5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java @@ -196,7 +196,7 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry { */ protected String getDescription(HttpServletRequest request) { return "[" + request.getServletPath() - + (request.getPathInfo() == null ? "" : request.getPathInfo()) + "]"; + + (request.getPathInfo() != null ? request.getPathInfo() : "") + "]"; } private void handleCommittedResponse(HttpServletRequest request, Throwable ex) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 6bed2b01cbd..eca12b4738d 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1477,7 +1477,7 @@ public class SpringApplicationTests { @Override public Resource getResource(String path) { Resource resource = this.resources.get(path); - return (resource == null ? new ClassPathResource("doesnotexist") : resource); + return (resource != null ? resource : new ClassPathResource("doesnotexist")); } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java index 26e18ce1b03..d487b94dfee 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java @@ -175,8 +175,8 @@ public class SpringApplicationAdminMXBeanRegistrarTests { try { return new ObjectName(jmxName); } - catch (MalformedObjectNameException e) { - throw new IllegalStateException("Invalid jmx name " + jmxName, e); + catch (MalformedObjectNameException ex) { + throw new IllegalStateException("Invalid jmx name " + jmxName, ex); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 7508ac23375..00be808123b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -474,7 +474,7 @@ public class ConfigFileApplicationListenerTests { } private String createLogForProfile(String profile) { - String suffix = profile != null ? "-" + profile : ""; + String suffix = (profile != null ? "-" + profile : ""); String string = ".properties)"; return "Loaded config file '" + new File("target/test-classes/application" + suffix + ".properties") diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java index 212fadf632d..0e5354999f6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java @@ -291,7 +291,7 @@ public class UndertowServletWebServerFactoryTests DeploymentInfo info = ((DeploymentManager) ReflectionTestUtils .getField(this.webServer, "manager")).getDeployment().getDeploymentInfo(); String charsetName = info.getLocaleCharsetMapping().get(locale.toString()); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } @Override diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java index 496839fb796..903b85ec79c 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java @@ -25,7 +25,7 @@ public interface HotelSummary { Double getAverageRating(); default Integer getAverageRatingRounded() { - return getAverageRating() == null ? null : (int) Math.round(getAverageRating()); + return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null); } } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java index 14f14f04668..0d7274bc24f 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java @@ -70,8 +70,9 @@ abstract class AbstractApplicationLauncher extends ExternalResource { private Process startApplication() throws Exception { File workingDirectory = getWorkingDirectory(); - File serverPortFile = workingDirectory == null ? new File("target/server.port") - : new File(workingDirectory, "target/server.port"); + File serverPortFile = (workingDirectory != null + ? new File(workingDirectory, "target/server.port") + : new File("target/server.port")); serverPortFile.delete(); File archive = this.applicationBuilder.buildApplication(); List arguments = new ArrayList<>(); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java index 3eb6033d15c..a99fea79ab0 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java @@ -107,14 +107,14 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher { } private String getClassesPath(File archive) { - return archive.getName().endsWith(".jar") ? "BOOT-INF/classes" - : "WEB-INF/classes"; + return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes" + : "WEB-INF/classes"); } private List getLibPaths(File archive) { - return archive.getName().endsWith(".jar") + return (archive.getName().endsWith(".jar") ? Collections.singletonList("BOOT-INF/lib") - : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"); + : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided")); } private void explodeArchive(File archive) throws IOException { diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java index 52bb10c6649..bb71be94876 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java @@ -54,9 +54,9 @@ class ExplodedApplicationLauncher extends AbstractApplicationLauncher { @Override protected List getArguments(File archive) { - String mainClass = archive.getName().endsWith(".war") + String mainClass = (archive.getName().endsWith(".war") ? "org.springframework.boot.loader.WarLauncher" - : "org.springframework.boot.loader.JarLauncher"; + : "org.springframework.boot.loader.JarLauncher"); try { explodeArchive(archive); return Arrays.asList("-cp", this.exploded.getAbsolutePath(), mainClass); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java index cae0c230669..c57206a9918 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java @@ -128,14 +128,14 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher { } private String getClassesPath(File archive) { - return archive.getName().endsWith(".jar") ? "BOOT-INF/classes" - : "WEB-INF/classes"; + return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes" + : "WEB-INF/classes"); } private List getLibPaths(File archive) { - return archive.getName().endsWith(".jar") + return (archive.getName().endsWith(".jar") ? Collections.singletonList("BOOT-INF/lib") - : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"); + : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided")); } private void explodeArchive(File archive, File destination) throws IOException {