From 41efea51a7171044b5f90b28822fd9dc7e665e33 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 3 May 2018 13:08:20 -0700 Subject: [PATCH] Polish ternary expressions Consistently format ternary expressions and always favor `!=` as the the check. --- .../CloudFoundryWebEndpointDiscoverer.java | 2 +- ...CloudFoundryActuatorAutoConfiguration.java | 5 ++-- ...CloudFoundryActuatorAutoConfiguration.java | 4 ++-- .../condition/ConditionsReportEndpoint.java | 4 ++-- ...earchHealthIndicatorAutoConfiguration.java | 2 +- ...ourceHealthIndicatorAutoConfiguration.java | 2 +- .../metrics/PropertiesMeterFilter.java | 6 ++--- .../WavefrontPropertiesConfigAdapter.java | 2 +- .../TomcatMetricsAutoConfiguration.java | 2 +- ...entContextConfigurationImportSelector.java | 5 ++-- .../servlet/MockServletWebServerFactory.java | 8 ++++--- .../actuate/audit/AuditEventsEndpoint.java | 10 ++++++-- .../boot/actuate/beans/BeansEndpoint.java | 6 ++--- ...ConfigurationPropertiesReportEndpoint.java | 2 +- .../ElasticsearchHealthIndicator.java | 2 +- .../annotation/EndpointDiscoverer.java | 2 +- .../JacksonJmxOperationResponseMapper.java | 2 +- .../endpoint/web/PathMappedEndpoints.java | 8 +++---- .../web/ServletEndpointRegistrar.java | 2 +- .../jersey/JerseyEndpointResourceFactory.java | 2 +- ...AbstractWebFluxEndpointHandlerMapping.java | 6 ++--- .../AbstractWebMvcEndpointHandlerMapping.java | 6 ++--- .../boot/actuate/env/EnvironmentEndpoint.java | 10 ++++++-- .../boot/actuate/flyway/FlywayEndpoint.java | 4 ++-- .../CompositeReactiveHealthIndicator.java | 4 ++-- .../jdbc/DataSourceHealthIndicator.java | 2 +- .../actuate/liquibase/LiquibaseEndpoint.java | 6 ++--- .../boot/actuate/logging/LoggersEndpoint.java | 2 +- .../management/HeapDumpWebEndpoint.java | 2 +- .../boot/actuate/metrics/MetricsEndpoint.java | 15 ++++++++---- ...faultRestTemplateExchangeTagsProvider.java | 4 ++-- .../web/client/RestTemplateExchangeTags.java | 2 +- .../metrics/web/servlet/WebMvcTags.java | 7 +++--- .../trace/http/HttpExchangeTracer.java | 2 +- .../web/mappings/MappingsEndpoint.java | 4 ++-- .../DispatcherServletHandlerMappings.java | 2 +- .../trace/reactive/HttpTraceWebFilter.java | 24 +++++++++---------- .../ServerWebExchangeTraceableRequest.java | 4 ++-- .../reactive/TraceableServerHttpResponse.java | 4 ++-- .../web/trace/servlet/HttpTraceFilter.java | 7 +++--- ...gurationPropertiesReportEndpointTests.java | 2 +- .../ReflectiveOperationInvokerTests.java | 2 +- .../jmx/JmxEndpointExporterTests.java | 5 ++-- .../endpoint/jmx/TestJmxOperation.java | 4 ++-- .../AbstractWebEndpointIntegrationTests.java | 4 ++-- .../trace/http/HttpExchangeTracerTests.java | 4 ++-- .../flyway/FlywayAutoConfiguration.java | 2 +- ...grationAutoConfigurationScanRegistrar.java | 4 ++-- .../jdbc/DataSourceProperties.java | 12 +++++----- .../liquibase/LiquibaseAutoConfiguration.java | 2 +- .../mongo/MongoClientFactory.java | 10 ++++---- .../mongo/ReactiveMongoClientFactory.java | 12 +++++----- .../jpa/DataSourceInitializedPublisher.java | 4 ++-- ...h2ClientPropertiesRegistrationAdapter.java | 12 +++++----- .../session/SessionStoreMappings.java | 2 +- .../TransactionManagerCustomizers.java | 4 ++-- .../TomcatWebServerFactoryCustomizer.java | 4 ++-- .../AbstractErrorWebExceptionHandler.java | 2 +- .../web/servlet/WebMvcAutoConfiguration.java | 2 +- ...stJpaDependencyAutoConfigurationTests.java | 2 +- .../servlet/MockServletWebServerFactory.java | 8 ++++--- .../cli/command/options/SourceOptions.java | 2 +- .../springframework/boot/cli/CliTester.java | 2 +- .../restart/classloader/ClassLoaderFile.java | 2 +- .../test/MockClientHttpRequestFactory.java | 2 +- .../migrator/PropertiesMigrationReport.java | 2 +- .../assertj/ApplicationContextAssert.java | 4 ++-- .../runner/WebApplicationContextRunner.java | 4 ++-- .../boot/test/util/TestPropertyValues.java | 2 +- .../test/web/client/TestRestTemplate.java | 6 ++--- ...figurationMetadataAnnotationProcessor.java | 2 +- .../javac/JavaCompilerFieldValuesParser.java | 2 +- .../boot/gradle/dsl/SpringBootExtension.java | 2 +- .../boot/gradle/plugin/JavaPluginAction.java | 4 ++-- .../gradle/tasks/buildinfo/BuildInfo.java | 10 ++++---- .../boot/gradle/tasks/bundling/BootJar.java | 6 ++--- .../boot/gradle/tasks/bundling/BootWar.java | 6 ++--- .../tasks/bundling/BootZipCopyAction.java | 4 ++-- .../boot/loader/jar/AsciiBytes.java | 4 ++-- .../boot/loader/jar/JarFile.java | 4 ++-- .../boot/loader/jar/StringSequence.java | 2 +- .../PropertiesMergingResourceTransformer.java | 2 +- .../org/springframework/boot/ImageBanner.java | 6 ++--- .../boot/SpringApplication.java | 4 ++-- ...ontextIdApplicationContextInitializer.java | 2 +- .../config/ConfigFileApplicationListener.java | 4 ++-- ...urationPropertiesBindingPostProcessor.java | 5 ++-- ...ConfigurationPropertiesImportSelector.java | 4 ++-- .../properties/bind/BindException.java | 2 +- .../context/properties/bind/BindResult.java | 2 +- .../context/properties/bind/Bindable.java | 6 ++--- .../properties/bind/CollectionBinder.java | 4 ++-- .../bind/IndexedElementsBinder.java | 2 +- .../properties/bind/JavaBeanBinder.java | 2 +- .../context/properties/bind/MapBinder.java | 6 ++--- .../bind/handler/IgnoreErrorsBindHandler.java | 2 +- .../source/ConfigurationPropertyName.java | 4 ++-- ...gurationPropertySourcesPropertySource.java | 2 +- .../MapConfigurationPropertySource.java | 2 +- .../CollectionToDelimitedStringConverter.java | 2 +- .../DelimitedStringToArrayConverter.java | 2 +- .../DelimitedStringToCollectionConverter.java | 2 +- .../convert/DurationToNumberConverter.java | 2 +- .../convert/DurationToStringConverter.java | 4 ++-- .../convert/NumberToDurationConverter.java | 2 +- .../convert/StringToDurationConverter.java | 4 ++-- ...igurationPropertyValueFailureAnalyzer.java | 4 ++-- .../boot/env/YamlPropertySourceLoader.java | 2 +- .../boot/jdbc/DataSourceBuilder.java | 4 ++-- .../boot/json/AbstractJsonParser.java | 2 +- .../boot/origin/OriginTrackedValue.java | 2 +- .../boot/origin/TextResourceOrigin.java | 4 ++-- .../springframework/boot/util/LambdaSafe.java | 22 ++++++++--------- .../jetty/JettyServletWebServerFactory.java | 8 +++---- .../embedded/netty/SslServerCustomizer.java | 4 ++-- .../undertow/SslBuilderCustomizer.java | 4 ++-- .../UndertowReactiveWebServerFactory.java | 4 ++-- .../UndertowServletWebServerFactory.java | 2 +- .../embedded/undertow/UndertowWebServer.java | 4 ++-- .../error/DefaultErrorAttributes.java | 2 +- .../boot/web/servlet/server/DocumentRoot.java | 2 +- ...iasedConfigurationPropertySourceTests.java | 2 +- .../MapConfigurationPropertySourceTests.java | 2 +- .../OriginTrackedPropertiesLoaderTests.java | 2 +- .../boot/origin/MockOrigin.java | 2 +- .../JettyServletWebServerFactoryTests.java | 2 +- .../TomcatServletWebServerFactoryTests.java | 5 ++-- .../server/MockServletWebServerFactory.java | 8 ++++--- 128 files changed, 285 insertions(+), 257 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java index 110da408f8..38566757bf 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java @@ -72,7 +72,7 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer { AnnotationAttributes attributes = AnnotatedElementUtils .getMergedAnnotationAttributes(extensionBean.getClass(), EndpointWebExtension.class); - Class endpoint = (attributes == null ? null : attributes.getClass("endpoint")); + Class endpoint = (attributes != null ? attributes.getClass("endpoint") : null); return (endpoint != null && HealthEndpoint.class.isAssignableFrom(endpoint)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java index 5ccda4dd9b..2638905105 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java @@ -126,9 +126,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration { String cloudControllerUrl = environment.getProperty("vcap.application.cf_api"); boolean skipSslValidation = environment.getProperty( "management.cloudfoundry.skip-ssl-validation", Boolean.class, false); - return (cloudControllerUrl == null ? null - : new ReactiveCloudFoundrySecurityService(webClientBuilder, - cloudControllerUrl, skipSslValidation)); + return (cloudControllerUrl != null ? new ReactiveCloudFoundrySecurityService( + webClientBuilder, cloudControllerUrl, skipSslValidation) : null); } private CorsConfiguration getCorsConfiguration() { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java index 3d12e47398..9f7d5f5b46 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java @@ -130,8 +130,8 @@ public class CloudFoundryActuatorAutoConfiguration { String cloudControllerUrl = environment.getProperty("vcap.application.cf_api"); boolean skipSslValidation = environment.getProperty( "management.cloudfoundry.skip-ssl-validation", Boolean.class, false); - return (cloudControllerUrl == null ? null : new CloudFoundrySecurityService( - restTemplateBuilder, cloudControllerUrl, skipSslValidation)); + return (cloudControllerUrl != null ? new CloudFoundrySecurityService( + restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null); } private CorsConfiguration getCorsConfiguration() { 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 08f705f55b..ba471945a9 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 @@ -125,8 +125,8 @@ public class ConditionsReportEndpoint { this.unconditionalClasses = report.getUnconditionalClasses(); report.getConditionAndOutcomesBySource().forEach( (source, conditionAndOutcomes) -> add(source, conditionAndOutcomes)); - this.parentId = context.getParent() == null ? null - : context.getParent().getId(); + this.parentId = (context.getParent() != null ? context.getParent().getId() + : null); } private void add(String source, ConditionAndOutcomes conditionAndOutcomes) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java index 0c382594b0..ecb984b9d5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java @@ -82,7 +82,7 @@ public class ElasticsearchHealthIndicatorAutoConfiguration { protected ElasticsearchHealthIndicator createHealthIndicator(Client client) { Duration responseTimeout = this.properties.getResponseTimeout(); return new ElasticsearchHealthIndicator(client, - responseTimeout == null ? 100 : responseTimeout.toMillis(), + responseTimeout != null ? responseTimeout.toMillis() : 100, this.properties.getIndices()); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java index f09924255b..4f1f155ee6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java @@ -112,7 +112,7 @@ public class DataSourceHealthIndicatorAutoConfiguration extends private String getValidationQuery(DataSource source) { DataSourcePoolMetadata poolMetadata = this.poolMetadataProvider .getDataSourcePoolMetadata(source); - return (poolMetadata == null ? null : poolMetadata.getValidationQuery()); + return (poolMetadata != null ? poolMetadata.getValidationQuery() : null); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index da9964e454..130b1f7db2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java @@ -68,10 +68,10 @@ public class PropertiesMeterFilter implements MeterFilter { } private long[] convertSla(Meter.Type meterType, ServiceLevelAgreementBoundary[] sla) { - long[] converted = Arrays.stream(sla == null ? EMPTY_SLA : sla) + long[] converted = Arrays.stream(sla != null ? sla : EMPTY_SLA) .map((candidate) -> candidate.getValue(meterType)) .filter(Objects::nonNull).mapToLong(Long::longValue).toArray(); - return (converted.length == 0 ? null : converted); + return (converted.length != 0 ? converted : null); } private T lookup(Map values, Id id, T defaultValue) { @@ -82,7 +82,7 @@ public class PropertiesMeterFilter implements MeterFilter { return result; } int lastDot = name.lastIndexOf('.'); - name = lastDot == -1 ? "" : name.substring(0, lastDot); + name = (lastDot != -1 ? name.substring(0, lastDot) : ""); } return values.getOrDefault("all", defaultValue); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java index d2c6b1ca81..5d873338ba 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java @@ -60,7 +60,7 @@ public class WavefrontPropertiesConfigAdapter } private String getUriAsString(WavefrontProperties properties) { - return properties.getUri() == null ? null : properties.getUri().toString(); + return (properties.getUri() != null ? properties.getUri().toString() : null); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java index 59c842bfe3..ba2ff2570c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java @@ -47,7 +47,7 @@ public class TomcatMetricsAutoConfiguration { @Bean @ConditionalOnMissingBean public TomcatMetrics tomcatMetrics() { - return new TomcatMetrics(this.context == null ? null : this.context.getManager(), + return new TomcatMetrics(this.context != null ? this.context.getManager() : null, Collections.emptyList()); } 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 528979623d..ad9c37f9a5 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 @@ -125,8 +125,9 @@ class ManagementContextConfigurationImportSelector Map annotationAttributes = annotationMetadata .getAnnotationAttributes( ManagementContextConfiguration.class.getName()); - return (annotationAttributes == null ? ManagementContextType.ANY - : (ManagementContextType) annotationAttributes.get("value")); + return (annotationAttributes != null + ? (ManagementContextType) annotationAttributes.get("value") + : ManagementContextType.ANY); } private int readOrder(AnnotationMetadata annotationMetadata) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java index 6eb8056358..6f2a7aa28d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java @@ -52,15 +52,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return getWebServer() == null ? null : getWebServer().getServletContext(); + return (getWebServer() != null ? getWebServer().getServletContext() : null); } public RegisteredServlet getRegisteredServlet(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index); + return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) + : null); } public RegisteredFilter getRegisteredFilter(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index); + return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) + : null); } public static class MockServletWebServer diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java index ae56fb46ef..f5936ef18c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.audit; +import java.time.Instant; import java.time.OffsetDateTime; import java.util.List; @@ -43,8 +44,13 @@ public class AuditEventsEndpoint { @ReadOperation public AuditEventsDescriptor events(@Nullable String principal, @Nullable OffsetDateTime after, @Nullable String type) { - return new AuditEventsDescriptor(this.auditEventRepository.find(principal, - after == null ? null : after.toInstant(), type)); + List events = this.auditEventRepository.find(principal, + getInstant(after), type); + return new AuditEventsDescriptor(events); + } + + private Instant getInstant(OffsetDateTime offsetDateTime) { + return (offsetDateTime != null ? offsetDateTime.toInstant() : null); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java index 7fb7314a25..41afc71c16 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java @@ -119,7 +119,7 @@ public class BeansEndpoint { } ConfigurableApplicationContext parent = getConfigurableParent(context); return new ContextBeans(describeBeans(context.getBeanFactory()), - parent == null ? null : parent.getId()); + parent != null ? parent.getId() : null); } private static Map describeBeans( @@ -168,8 +168,8 @@ public class BeansEndpoint { private BeanDescriptor(String[] aliases, String scope, Class type, String resource, String[] dependencies) { this.aliases = aliases; - this.scope = StringUtils.hasText(scope) ? scope - : BeanDefinition.SCOPE_SINGLETON; + this.scope = (StringUtils.hasText(scope) ? scope + : BeanDefinition.SCOPE_SINGLETON); this.type = type; this.resource = resource; this.dependencies = dependencies; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index 3d611ee3ec..0c4e7b68b1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -118,7 +118,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext prefix, sanitize(prefix, safeSerialize(mapper, bean, prefix)))); }); return new ContextConfigurationProperties(beanDescriptors, - context.getParent() == null ? null : context.getParent().getId()); + context.getParent() != null ? context.getParent().getId() : null); } private ConfigurationBeanFactoryMetadata getBeanFactoryMetadata( diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java index 2ae834524c..5fdd8d3ad8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java @@ -55,7 +55,7 @@ public class ElasticsearchHealthIndicator extends AbstractHealthIndicator { public ElasticsearchHealthIndicator(Client client, long responseTimeout, List indices) { this(client, responseTimeout, - (indices == null ? null : StringUtils.toStringArray(indices))); + (indices != null ? StringUtils.toStringArray(indices) : null)); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index e8c253c113..d66451ede4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -224,7 +224,7 @@ public abstract class EndpointDiscoverer, O exten } private T getLast(List list) { - return CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1); + return (CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1)); } private void assertNoDuplicateOperations(EndpointBean endpointBean, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java index a75a9eb2a0..13653db37f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java @@ -39,7 +39,7 @@ public class JacksonJmxOperationResponseMapper implements JmxOperationResponseMa private final JavaType mapType; public JacksonJmxOperationResponseMapper(ObjectMapper objectMapper) { - this.objectMapper = (objectMapper == null ? new ObjectMapper() : objectMapper); + this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper()); this.listType = this.objectMapper.getTypeFactory() .constructParametricType(List.class, Object.class); this.mapType = this.objectMapper.getTypeFactory() diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java index 16fe456d1d..b3d3b97eab 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java @@ -46,7 +46,7 @@ public class PathMappedEndpoints implements Iterable { */ public PathMappedEndpoints(String basePath, EndpointsSupplier supplier) { Assert.notNull(supplier, "Supplier must not be null"); - this.basePath = (basePath == null ? "" : basePath); + this.basePath = (basePath != null ? basePath : ""); this.endpoints = getEndpoints(Collections.singleton(supplier)); } @@ -58,7 +58,7 @@ public class PathMappedEndpoints implements Iterable { public PathMappedEndpoints(String basePath, Collection> suppliers) { Assert.notNull(suppliers, "Suppliers must not be null"); - this.basePath = (basePath == null ? "" : basePath); + this.basePath = (basePath != null ? basePath : ""); this.endpoints = getEndpoints(suppliers); } @@ -91,7 +91,7 @@ public class PathMappedEndpoints implements Iterable { */ public String getRootPath(String endpointId) { PathMappedEndpoint endpoint = getEndpoint(endpointId); - return (endpoint == null ? null : endpoint.getRootPath()); + return (endpoint != null ? endpoint.getRootPath() : null); } /** @@ -144,7 +144,7 @@ public class PathMappedEndpoints implements Iterable { } private String getPath(PathMappedEndpoint endpoint) { - return (endpoint == null ? null : this.basePath + "/" + endpoint.getRootPath()); + return (endpoint != null ? this.basePath + "/" + endpoint.getRootPath() : null); } private List asList(Stream stream) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java index c2973caac9..9388ed10e8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java @@ -46,7 +46,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer { public ServletEndpointRegistrar(String basePath, Collection servletEndpoints) { Assert.notNull(servletEndpoints, "ServletEndpoints must not be null"); - this.basePath = (basePath == null ? "" : basePath); + this.basePath = (basePath != null ? basePath : ""); this.servletEndpoints = servletEndpoints; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java index e48c6f15ce..4a9bbe5f92 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java @@ -179,7 +179,7 @@ public class JerseyEndpointResourceFactory { Map result = new HashMap<>(); multivaluedMap.forEach((name, values) -> { if (!CollectionUtils.isEmpty(values)) { - result.put(name, values.size() == 1 ? values.get(0) : values); + result.put(name, values.size() != 1 ? values : values.get(0)); } }); return result; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index 1baeb06655..a309c3b575 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -309,7 +309,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping arguments.putAll(body); } exchange.getRequest().getQueryParams().forEach((name, values) -> arguments - .put(name, values.size() == 1 ? values.get(0) : values)); + .put(name, values.size() != 1 ? values : values.get(0))); return arguments; } @@ -323,8 +323,8 @@ public abstract class AbstractWebFluxEndpointHandlerMapping .onErrorMap(InvalidEndpointRequestException.class, (ex) -> new ResponseStatusException(HttpStatus.BAD_REQUEST, ex.getReason())) - .defaultIfEmpty(new ResponseEntity<>(httpMethod == HttpMethod.GET - ? HttpStatus.NOT_FOUND : HttpStatus.NO_CONTENT)); + .defaultIfEmpty(new ResponseEntity<>(httpMethod != HttpMethod.GET + ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND)); } private ResponseEntity toResponseEntity(Object response) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java index 8052cd020c..20dc83ea4e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java @@ -257,7 +257,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping arguments.putAll(body); } request.getParameterMap().forEach((name, values) -> arguments.put(name, - values.length == 1 ? values[0] : Arrays.asList(values))); + values.length != 1 ? Arrays.asList(values) : values[0])); return arguments; } @@ -269,8 +269,8 @@ public abstract class AbstractWebMvcEndpointHandlerMapping private Object handleResult(Object result, HttpMethod httpMethod) { if (result == null) { - return new ResponseEntity<>(httpMethod == HttpMethod.GET - ? HttpStatus.NOT_FOUND : HttpStatus.NO_CONTENT); + return new ResponseEntity<>(httpMethod != HttpMethod.GET + ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND); } if (!(result instanceof WebEndpointResponse)) { return result; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java index f380cdbddc..71d644d641 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java @@ -34,6 +34,7 @@ import org.springframework.boot.actuate.endpoint.annotation.Selector; import org.springframework.boot.context.properties.bind.PlaceholdersResolver; import org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; +import org.springframework.boot.origin.Origin; import org.springframework.boot.origin.OriginLookup; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; @@ -152,11 +153,16 @@ public class EnvironmentEndpoint { private PropertyValueDescriptor describeValueOf(String name, PropertySource source, PlaceholdersResolver resolver) { Object resolved = resolver.resolvePlaceholders(source.getProperty(name)); - String origin = (source instanceof OriginLookup) - ? ((OriginLookup) source).getOrigin(name).toString() : null; + String origin = ((source instanceof OriginLookup) + ? getOrigin((OriginLookup) source, name) : null); return new PropertyValueDescriptor(sanitize(name, resolved), origin); } + private String getOrigin(OriginLookup lookup, String name) { + Origin origin = lookup.getOrigin(name); + return (origin != null ? origin.toString() : null); + } + private PlaceholdersResolver getResolver() { return new PropertySourcesPlaceholdersSanitizingResolver(getPropertySources(), this.sanitizer); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java index 0b34913960..6f578acfc6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java @@ -59,7 +59,7 @@ public class FlywayEndpoint { .put(name, new FlywayDescriptor(flyway.info().all()))); ApplicationContext parent = target.getParent(); contextFlywayBeans.put(target.getId(), new ContextFlywayBeans(flywayBeans, - parent == null ? null : parent.getId())); + parent != null ? parent.getId() : null)); target = parent; } return new ApplicationFlywayBeans(contextFlywayBeans); @@ -170,7 +170,7 @@ public class FlywayEndpoint { } private String nullSafeToString(Object obj) { - return (obj == null ? null : obj.toString()); + return (obj != null ? obj.toString() : null); } public MigrationType getType() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java index ca19554f93..80e418eb8e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java @@ -57,8 +57,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator Assert.notNull(indicators, "Indicators must not be null"); this.indicators = new LinkedHashMap<>(indicators); this.healthAggregator = healthAggregator; - this.timeoutCompose = (mono) -> this.timeout != null ? mono.timeout( - Duration.ofMillis(this.timeout), Mono.just(this.timeoutHealth)) : mono; + this.timeoutCompose = (mono) -> (this.timeout != null ? mono.timeout( + Duration.ofMillis(this.timeout), Mono.just(this.timeoutHealth)) : mono); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java index ec7150ed32..faf1d7a3c3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java @@ -86,7 +86,7 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator super("DataSource health check failed"); this.dataSource = dataSource; this.query = query; - this.jdbcTemplate = (dataSource == null ? null : new JdbcTemplate(dataSource)); + this.jdbcTemplate = (dataSource != null ? new JdbcTemplate(dataSource) : null); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java index 772f00f770..71fc2d6af7 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java @@ -69,7 +69,7 @@ public class LiquibaseEndpoint { createReport(liquibase, service, factory))); ApplicationContext parent = target.getParent(); contextBeans.put(target.getId(), new ContextLiquibaseBeans(liquibaseBeans, - parent == null ? null : parent.getId())); + parent != null ? parent.getId() : null)); target = parent; } return new ApplicationLiquibaseBeans(contextBeans); @@ -204,8 +204,8 @@ public class LiquibaseEndpoint { this.execType = ranChangeSet.getExecType(); this.id = ranChangeSet.getId(); this.labels = ranChangeSet.getLabels().getLabels(); - this.checksum = ranChangeSet.getLastCheckSum() == null ? null - : ranChangeSet.getLastCheckSum().toString(); + this.checksum = (ranChangeSet.getLastCheckSum() != null + ? ranChangeSet.getLastCheckSum().toString() : null); this.orderExecuted = ranChangeSet.getOrderExecuted(); this.tag = ranChangeSet.getTag(); } 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 a44ebae8a1..1996e9c36f 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 @@ -73,7 +73,7 @@ public class LoggersEndpoint { Assert.notNull(name, "Name must not be null"); LoggerConfiguration configuration = this.loggingSystem .getLoggerConfiguration(name); - return (configuration == null ? null : new LoggerLevels(configuration)); + return (configuration != null ? new LoggerLevels(configuration) : null); } @WriteOperation diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java index d1ab51cf73..2982480dfc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java @@ -78,7 +78,7 @@ public class HeapDumpWebEndpoint { if (this.lock.tryLock(this.timeout, TimeUnit.MILLISECONDS)) { try { return new WebEndpointResponse<>( - dumpHeap(live == null ? true : live)); + dumpHeap(live != null ? live : true)); } finally { this.lock.unlock(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index 542c4c5d90..f175315062 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -96,10 +96,15 @@ public class MetricsEndpoint { } private List parseTags(List tags) { - return tags == null ? Collections.emptyList() : tags.stream().map((t) -> { - String[] tagParts = t.split(":", 2); - return Tag.of(tagParts[0], tagParts[1]); - }).collect(Collectors.toList()); + if (tags == null) { + return Collections.emptyList(); + } + return tags.stream().map(this::parseTag).collect(Collectors.toList()); + } + + private Tag parseTag(String tag) { + String[] parts = tag.split(":", 2); + return Tag.of(parts[0], parts[1]); } private void collectMeters(List meters, MeterRegistry registry, String name, @@ -125,7 +130,7 @@ public class MetricsEndpoint { } private BiFunction mergeFunction(Statistic statistic) { - return Statistic.MAX.equals(statistic) ? Double::max : Double::sum; + return (Statistic.MAX.equals(statistic) ? Double::max : Double::sum); } private Map> getAvailableTags(List meters) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java index d7a4231e5f..35eab2381f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/DefaultRestTemplateExchangeTagsProvider.java @@ -36,9 +36,9 @@ public class DefaultRestTemplateExchangeTagsProvider @Override public Iterable getTags(String urlTemplate, HttpRequest request, ClientHttpResponse response) { - Tag uriTag = StringUtils.hasText(urlTemplate) + Tag uriTag = (StringUtils.hasText(urlTemplate) ? RestTemplateExchangeTags.uri(urlTemplate) - : RestTemplateExchangeTags.uri(request); + : RestTemplateExchangeTags.uri(request)); return Arrays.asList(RestTemplateExchangeTags.method(request), uriTag, RestTemplateExchangeTags.status(response), RestTemplateExchangeTags.clientName(request)); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java index b960e8dcf4..60139b4324 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java @@ -64,7 +64,7 @@ public final class RestTemplateExchangeTags { * @return the uri tag */ public static Tag uri(String uriTemplate) { - String uri = StringUtils.hasText(uriTemplate) ? uriTemplate : "none"; + String uri = (StringUtils.hasText(uriTemplate) ? uriTemplate : "none"); return Tag.of("uri", ensureLeadingSlash(stripUri(uri))); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java index 3c79fe9d73..c6f96ba8c7 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java @@ -58,7 +58,7 @@ public final class WebMvcTags { * @return the method tag whose value is a capitalized method (e.g. GET). */ public static Tag method(HttpServletRequest request) { - return (request == null ? METHOD_UNKNOWN : Tag.of("method", request.getMethod())); + return (request != null ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN); } /** @@ -67,8 +67,9 @@ public final class WebMvcTags { * @return the status tag derived from the status of the response */ public static Tag status(HttpServletResponse response) { - return (response == null ? STATUS_UNKNOWN : - Tag.of("status", Integer.toString(response.getStatus()))); + return (response != null + ? Tag.of("status", Integer.toString(response.getStatus())) + : STATUS_UNKNOWN); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java index 95733a269d..13789c4ce2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java @@ -86,7 +86,7 @@ public class HttpExchangeTracer { } private T getIfIncluded(Include include, Supplier valueSupplier) { - return this.includes.contains(include) ? valueSupplier.get() : null; + return (this.includes.contains(include) ? valueSupplier.get() : null); } private void setIfIncluded(Include include, Supplier supplier, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java index c404aa7cee..6c647e6271 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java @@ -59,8 +59,8 @@ public class MappingsEndpoint { this.descriptionProviders .forEach((provider) -> mappings.put(provider.getMappingName(), provider.describeMappings(applicationContext))); - return new ContextMappings(mappings, applicationContext.getParent() == null ? null - : applicationContext.getId()); + return new ContextMappings(mappings, applicationContext.getParent() != null + ? applicationContext.getId() : null); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java index 6763d72b2b..4ab0d3b899 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java @@ -64,7 +64,7 @@ final class DispatcherServletHandlerMappings { initializeDispatcherServletIfPossible(); handlerMappings = this.dispatcherServlet.getHandlerMappings(); } - return handlerMappings == null ? Collections.emptyList() : handlerMappings; + return (handlerMappings != null ? handlerMappings : Collections.emptyList()); } private void initializeDispatcherServletIfPossible() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java index 95f814555c..837adc2cfe 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java @@ -73,11 +73,11 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { @Override public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - Mono principal = this.includes.contains(Include.PRINCIPAL) + Mono principal = (this.includes.contains(Include.PRINCIPAL) ? exchange.getPrincipal().cast(Object.class).defaultIfEmpty(NONE) - : Mono.just(NONE); - Mono session = this.includes.contains(Include.SESSION_ID) - ? exchange.getSession() : Mono.just(NONE); + : Mono.just(NONE)); + Mono session = (this.includes.contains(Include.SESSION_ID) + ? exchange.getSession() : Mono.just(NONE)); return Mono.zip(principal, session) .flatMap((tuple) -> filter(exchange, chain, asType(tuple.getT1(), Principal.class), @@ -97,17 +97,17 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { exchange); HttpTrace trace = this.tracer.receivedRequest(request); return chain.filter(exchange).doAfterSuccessOrError((aVoid, ex) -> { - this.tracer.sendingResponse(trace, - new TraceableServerHttpResponse(ex == null ? exchange.getResponse() - : new CustomStatusResponseDecorator(ex, - exchange.getResponse())), - () -> principal, () -> getStartedSessionId(session)); + TraceableServerHttpResponse response = new TraceableServerHttpResponse( + (ex != null ? new CustomStatusResponseDecorator(ex, + exchange.getResponse()) : exchange.getResponse())); + this.tracer.sendingResponse(trace, response, () -> principal, + () -> getStartedSessionId(session)); this.repository.add(trace); }); } private String getStartedSessionId(WebSession session) { - return (session != null && session.isStarted()) ? session.getId() : null; + return (session != null && session.isStarted() ? session.getId() : null); } private static final class CustomStatusResponseDecorator @@ -117,9 +117,9 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { private CustomStatusResponseDecorator(Throwable ex, ServerHttpResponse delegate) { super(delegate); - this.status = ex instanceof ResponseStatusException + this.status = (ex instanceof ResponseStatusException ? ((ResponseStatusException) ex).getStatus() - : HttpStatus.INTERNAL_SERVER_ERROR; + : HttpStatus.INTERNAL_SERVER_ERROR); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java index 30d41ea0a6..9daace7a71 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java @@ -45,8 +45,8 @@ class ServerWebExchangeTraceableRequest implements TraceableRequest { this.method = request.getMethodValue(); this.headers = request.getHeaders(); this.uri = request.getURI(); - this.remoteAddress = request.getRemoteAddress() == null ? null - : request.getRemoteAddress().getAddress().toString(); + this.remoteAddress = (request.getRemoteAddress() != null + ? request.getRemoteAddress().getAddress().toString() : null); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java index 63c4fedd13..9721d0fb3f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java @@ -38,8 +38,8 @@ class TraceableServerHttpResponse implements TraceableResponse { @Override public int getStatus() { - return this.response.getStatusCode() == null ? 200 - : this.response.getStatusCode().value(); + return (this.response.getStatusCode() != null + ? this.response.getStatusCode().value() : 200); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java index b044ef610c..25a70c33f4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java @@ -86,8 +86,9 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered { } finally { TraceableHttpServletResponse traceableResponse = new TraceableHttpServletResponse( - status == response.getStatus() ? response - : new CustomStatusResponseWrapper(response, status)); + status != response.getStatus() + ? new CustomStatusResponseWrapper(response, status) + : response); this.tracer.sendingResponse(trace, traceableResponse, request::getUserPrincipal, () -> getSessionId(request)); this.repository.add(trace); @@ -96,7 +97,7 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered { private String getSessionId(HttpServletRequest request) { HttpSession session = request.getSession(false); - return session == null ? null : session.getId(); + return (session != null ? session.getId() : null); } private static final class CustomStatusResponseWrapper diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java index e717b99533..8de2b2426f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java @@ -255,7 +255,7 @@ public class ConfigurationPropertiesReportEndpointTests { } public boolean isMixedBoolean() { - return (this.mixedBoolean == null ? false : this.mixedBoolean); + return (this.mixedBoolean != null ? this.mixedBoolean : false); } public void setMixedBoolean(Boolean mixedBoolean) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java index 9bb76d960a..66f848b947 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java @@ -57,7 +57,7 @@ public class ReflectiveOperationInvokerTests { ReflectionUtils.findMethod(Example.class, "reverse", String.class), OperationType.READ); this.parameterValueMapper = (parameter, - value) -> (value == null ? null : value.toString()); + value) -> (value != null ? value.toString() : null); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java index 29d9af6ca3..01759b1098 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java @@ -190,8 +190,9 @@ public class JmxEndpointExporterTests { @Override public ObjectName getObjectName(ExposableJmxEndpoint endpoint) throws MalformedObjectNameException { - return (endpoint == null ? null - : new ObjectName("boot:type=Endpoint,name=" + endpoint.getId())); + return (endpoint != null + ? new ObjectName("boot:type=Endpoint,name=" + endpoint.getId()) + : null); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java index 557cd3f4fe..1da6edd794 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java @@ -68,8 +68,8 @@ public class TestJmxOperation implements JmxOperation { @Override public Object invoke(InvocationContext context) { - return (this.invoke == null ? "result" - : this.invoke.apply(context.getArguments())); + return (this.invoke != null ? this.invoke.apply(context.getArguments()) + : "result"); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index afdc9f86cf..2786f2694d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -835,7 +835,7 @@ public abstract class AbstractWebEndpointIntegrationTests property, Supplier defaultValue) { String value = property.get(); - return (value == null ? defaultValue.get() : value); + return (value != null ? value : defaultValue.get()); } private void checkLocationExists(String... locations) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java index 9836a578bb..4b55d41a65 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java @@ -56,9 +56,9 @@ class IntegrationAutoConfigurationScanRegistrar extends IntegrationComponentScan @Override protected Collection getBasePackages( AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { - return AutoConfigurationPackages.has(this.beanFactory) + return (AutoConfigurationPackages.has(this.beanFactory) ? AutoConfigurationPackages.get(this.beanFactory) - : Collections.emptyList(); + : Collections.emptyList()); } @IntegrationComponentScan diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java index 27767dfe8c..839bfacdb3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java @@ -234,8 +234,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB } if (!StringUtils.hasText(driverClassName)) { throw new DataSourceBeanCreationException( - "Failed to determine a suitable driver class", - this, this.embeddedDatabaseConnection); + "Failed to determine a suitable driver class", this, + this.embeddedDatabaseConnection); } return driverClassName; } @@ -277,12 +277,12 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB return this.url; } String databaseName = determineDatabaseName(); - String url = (databaseName == null ? null - : this.embeddedDatabaseConnection.getUrl(databaseName)); + String url = (databaseName != null + ? this.embeddedDatabaseConnection.getUrl(databaseName) : null); if (!StringUtils.hasText(url)) { throw new DataSourceBeanCreationException( - "Failed to determine suitable jdbc url", - this, this.embeddedDatabaseConnection); + "Failed to determine suitable jdbc url", this, + this.embeddedDatabaseConnection); } return url; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java index 3667f70b11..0ef3992e0b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java @@ -168,7 +168,7 @@ public class LiquibaseAutoConfiguration { private String getProperty(Supplier property, Supplier defaultValue) { String value = property.get(); - return value == null ? defaultValue.get() : value; + return (value != null ? value : defaultValue.get()); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java index 6550836239..5aee853903 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java @@ -81,8 +81,8 @@ public class MongoClientFactory { if (options == null) { options = MongoClientOptions.builder().build(); } - String host = this.properties.getHost() == null ? "localhost" - : this.properties.getHost(); + String host = (this.properties.getHost() != null ? this.properties.getHost() + : "localhost"); return new MongoClient(Collections.singletonList(new ServerAddress(host, port)), options); } @@ -101,8 +101,8 @@ public class MongoClientFactory { int port = getValue(properties.getPort(), MongoProperties.DEFAULT_PORT); List seeds = Collections .singletonList(new ServerAddress(host, port)); - return credentials == null ? new MongoClient(seeds, options) - : new MongoClient(seeds, credentials, options); + return (credentials != null ? new MongoClient(seeds, credentials, options) + : new MongoClient(seeds, options)); } return createMongoClient(MongoProperties.DEFAULT_URI, options); } @@ -112,7 +112,7 @@ public class MongoClientFactory { } private T getValue(T value, T fallback) { - return (value == null ? fallback : value); + return (value != null ? value : fallback); } private boolean hasCustomAddress() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java index d438ac70b8..0664cd14fd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java @@ -86,8 +86,8 @@ public class ReactiveMongoClientFactory { private MongoClient createEmbeddedMongoClient(MongoClientSettings settings, int port) { Builder builder = builder(settings); - String host = this.properties.getHost() == null ? "localhost" - : this.properties.getHost(); + String host = (this.properties.getHost() != null ? this.properties.getHost() + : "localhost"); ClusterSettings clusterSettings = ClusterSettings.builder() .hosts(Collections.singletonList(new ServerAddress(host, port))).build(); builder.clusterSettings(clusterSettings); @@ -119,16 +119,16 @@ public class ReactiveMongoClientFactory { } private void applyCredentials(Builder builder) { - String database = this.properties.getAuthenticationDatabase() == null - ? this.properties.getMongoClientDatabase() - : this.properties.getAuthenticationDatabase(); + String database = (this.properties.getAuthenticationDatabase() != null + ? this.properties.getAuthenticationDatabase() + : this.properties.getMongoClientDatabase()); builder.credential((MongoCredential.createCredential( this.properties.getUsername(), database, this.properties.getPassword()))); } private T getOrDefault(T value, T defaultValue) { - return (value == null ? defaultValue : value); + return (value != null ? value : defaultValue); } private MongoClient createMongoClient(Builder builder) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java index 4162e9d1e9..b880a816a2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java @@ -91,8 +91,8 @@ class DataSourceInitializedPublisher implements BeanPostProcessor { if (this.properties == null) { return true; // better safe than sorry } - Supplier defaultDdlAuto = () -> EmbeddedDatabaseConnection - .isEmbedded(dataSource) ? "create-drop" : "none"; + Supplier defaultDdlAuto = () -> (EmbeddedDatabaseConnection + .isEmbedded(dataSource) ? "create-drop" : "none"); Map hibernate = this.properties .getHibernateProperties(new HibernateSettings().ddlAuto(defaultDdlAuto)); if (hibernate.containsKey("hibernate.hbm2ddl.auto")) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java index 95909b46da..b0a76ddb2b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java @@ -72,8 +72,8 @@ final class OAuth2ClientPropertiesRegistrationAdapter { private static Builder getBuilder(String registrationId, String configuredProviderId, Map providers) { - String providerId = (configuredProviderId == null ? registrationId - : configuredProviderId); + String providerId = (configuredProviderId != null ? configuredProviderId + : registrationId); CommonOAuth2Provider provider = getCommonProvider(providerId); if (provider == null && !providers.containsKey(providerId)) { throw new IllegalStateException( @@ -89,10 +89,10 @@ final class OAuth2ClientPropertiesRegistrationAdapter { private static String getErrorMessage(String configuredProviderId, String registrationId) { - return (configuredProviderId == null - ? "Provider ID must be specified for client registration '" - + registrationId + "'" - : "Unknown provider ID '" + configuredProviderId + "'"); + return (configuredProviderId != null + ? "Unknown provider ID '" + configuredProviderId + "'" + : "Provider ID must be specified for client registration '" + + registrationId + "'"); } private static Builder getBuilder(Builder builder, Provider provider) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java index cc75016040..a659958ae0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java @@ -93,7 +93,7 @@ final class SessionStoreMappings { } private String getName(Class configuration) { - return (configuration == null ? null : configuration.getName()); + return (configuration != null ? configuration.getName() : null); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java index 68e8f5a3f0..c965588d85 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java @@ -36,8 +36,8 @@ public class TransactionManagerCustomizers { public TransactionManagerCustomizers( Collection> customizers) { - this.customizers = (customizers == null ? Collections.emptyList() - : new ArrayList<>(customizers)); + this.customizers = (customizers != null ? new ArrayList<>(customizers) + : Collections.emptyList()); } @SuppressWarnings("unchecked") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java index 0e02cdfad9..b1e2c0272b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java @@ -110,9 +110,9 @@ public class TomcatWebServerFactoryCustomizer implements } private int determineMaxHttpHeaderSize() { - return this.serverProperties.getMaxHttpHeaderSize() > 0 + return (this.serverProperties.getMaxHttpHeaderSize() > 0 ? this.serverProperties.getMaxHttpHeaderSize() - : this.serverProperties.getTomcat().getMaxHttpHeaderSize(); + : this.serverProperties.getTomcat().getMaxHttpHeaderSize()); } private void customizeAcceptCount(ConfigurableTomcatWebServerFactory factory, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java index 44322ca13a..4fa410548a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java @@ -205,7 +205,7 @@ public abstract class AbstractErrorWebExceptionHandler } private String htmlEscape(Object input) { - return (input == null ? null : HtmlUtils.htmlEscape(input.toString())); + return (input != null ? HtmlUtils.htmlEscape(input.toString()) : null); } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index cb6dc3fc01..4299cd148a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -338,7 +338,7 @@ public class WebMvcAutoConfiguration { } private Integer getSeconds(Duration cachePeriod) { - return (cachePeriod == null ? null : (int) cachePeriod.getSeconds()); + return (cachePeriod != null ? (int) cachePeriod.getSeconds() : null); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java index 2a48446cf3..65fd58ca5c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java @@ -102,7 +102,7 @@ public class HazelcastJpaDependencyAutoConfigurationTests { String[] dependsOn = ((BeanDefinitionRegistry) context .getSourceApplicationContext()).getBeanDefinition("entityManagerFactory") .getDependsOn(); - return dependsOn != null ? Arrays.asList(dependsOn) : Collections.emptyList(); + return (dependsOn != null ? Arrays.asList(dependsOn) : Collections.emptyList()); } @Configuration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java index dc3a777d57..3c15e9bccb 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java @@ -52,15 +52,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return getWebServer() == null ? null : getWebServer().getServletContext(); + return (getWebServer() != null ? getWebServer().getServletContext() : null); } public RegisteredServlet getRegisteredServlet(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index); + return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) + : null); } public RegisteredFilter getRegisteredFilter(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index); + return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) + : null); } public static class MockServletWebServer diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java index 172fa598b9..78695d83ad 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java @@ -130,7 +130,7 @@ public class SourceOptions { } private String asString(Object arg) { - return (arg == null ? null : String.valueOf(arg)); + return (arg != null ? String.valueOf(arg) : null); } public List getSources() { diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java index af218ce23a..e18d5500fb 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java @@ -154,7 +154,7 @@ public class CliTester implements TestRule { } } else { - sources[i] = new File(arg).isAbsolute() ? arg : this.prefix + arg; + sources[i] = (new File(arg).isAbsolute() ? arg : this.prefix + arg); } } return sources; 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 278538065d..6b52921383 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 @@ -56,7 +56,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, - () -> "Contents must " + (kind == Kind.DELETED ? "" : "not ") + () -> "Contents must " + (kind != Kind.DELETED ? "not " : "") + "be null"); this.kind = kind; this.lastModified = lastModified; diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java index f7f11276a5..664906057a 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java @@ -119,7 +119,7 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory { public ClientHttpResponse asHttpResponse(AtomicLong seq) { MockClientHttpResponse httpResponse = new MockClientHttpResponse( - this.payload == null ? NO_DATA : this.payload, this.status); + this.payload != null ? this.payload : NO_DATA, this.status); waitForDelay(); if (this.payload != null) { httpResponse.getHeaders().setContentLength(this.payload.length); diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java index 01c2a3841d..a193c3bca3 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java @@ -148,7 +148,7 @@ class PropertiesMigrationReport { } private List asNewList(List source) { - return (source == null ? Collections.emptyList() : new ArrayList<>(source)); + return (source != null ? new ArrayList<>(source) : Collections.emptyList()); } public List getRenamed() { diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java index 92f51b045b..4e2d1aaa8c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java @@ -278,8 +278,8 @@ public class ApplicationContextAssert "%nExpecting:%n <%s>%nsingle bean of type:%n <%s>%nbut found:%n <%s>", getApplicationContext(), type, names)); } - T bean = (names.length == 0 ? null - : getApplicationContext().getBean(names[0], type)); + T bean = (names.length != 0 ? getApplicationContext().getBean(names[0], type) + : null); return Assertions.assertThat(bean).as("Bean of type <%s> from <%s>", type, getApplicationContext()); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java index e104390f86..ff5fe56abb 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java @@ -93,11 +93,11 @@ public final class WebApplicationContextRunner extends */ public static Supplier withMockServletContext( Supplier contextFactory) { - return (contextFactory == null ? null : () -> { + return (contextFactory != null ? () -> { ConfigurableWebApplicationContext context = contextFactory.get(); context.setServletContext(new MockServletContext()); return context; - }); + } : null); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 63639fd5aa..83f2fb8f5c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -235,7 +235,7 @@ public final class TestPropertyValues { } protected String applySuffix(String name) { - return (this.suffix == null ? name : name + "-" + this.suffix); + return (this.suffix != null ? name + "-" + this.suffix : name); } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index 4c9e845d2e..e4061073eb 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -130,7 +130,7 @@ public class TestRestTemplate { */ public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username, String password, HttpClientOption... httpClientOptions) { - this(restTemplateBuilder == null ? null : restTemplateBuilder.build(), username, + this(restTemplateBuilder != null ? restTemplateBuilder.build() : null, username, password, httpClientOptions); } @@ -138,8 +138,8 @@ public class TestRestTemplate { HttpClientOption... httpClientOptions) { Assert.notNull(restTemplate, "RestTemplate must not be null"); this.httpClientOptions = httpClientOptions; - if (getRequestFactoryClass(restTemplate).isAssignableFrom( - HttpComponentsClientHttpRequestFactory.class)) { + if (getRequestFactoryClass(restTemplate) + .isAssignableFrom(HttpComponentsClientHttpRequestFactory.class)) { restTemplate.setRequestFactory( new CustomHttpComponentsClientHttpRequestFactory(httpClientOptions)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 6affbde16f..528eada8ca 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -423,7 +423,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor this.metadataCollector.add(ItemMetadata.newProperty(endpointKey, "enabled", Boolean.class.getName(), type, null, String.format("Whether to enable the %s endpoint.", endpointId), - (enabledByDefault == null ? true : enabledByDefault), null)); + (enabledByDefault != null ? enabledByDefault : true), null)); if (hasMainReadOperation(element)) { this.metadataCollector.add(ItemMetadata.newProperty(endpointKey, "cache.time-to-live", Duration.class.getName(), type, null, diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java index e95ea97f2f..0e0aa7f346 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java @@ -178,7 +178,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser { String type = instance.toString(); type = type.substring(DURATION_OF.length(), type.indexOf('(')); String suffix = DURATION_SUFFIX.get(type); - return (suffix == null ? null : factoryValue + suffix); + return (suffix != null ? factoryValue + suffix : null); } return factoryValue; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java index e5f3dc44a7..884908f3b7 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java @@ -119,7 +119,7 @@ public class SpringBootExtension { private String determineArtifactBaseName() { Jar artifactTask = findArtifactTask(); - return (artifactTask == null ? null : artifactTask.getBaseName()); + return (artifactTask != null ? artifactTask.getBaseName() : null); } private Jar findArtifactTask() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java index 400aecbb8f..c6ed35affa 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java @@ -162,9 +162,9 @@ final class JavaPluginAction implements PluginApplicationAction { } private boolean hasConfigurationProcessorOnClasspath(JavaCompile compile) { - Set files = compile.getOptions().getAnnotationProcessorPath() != null + Set files = (compile.getOptions().getAnnotationProcessorPath() != null ? compile.getOptions().getAnnotationProcessorPath().getFiles() - : compile.getClasspath().getFiles(); + : compile.getClasspath().getFiles()); return files.stream().map(File::getName).anyMatch( (name) -> name.startsWith("spring-boot-configuration-processor")); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java index ab62014981..310bffb99d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java @@ -57,9 +57,9 @@ public class BuildInfo extends ConventionTask { new File(getDestinationDir(), "build-info.properties")) .writeBuildProperties(new ProjectDetails( this.properties.getGroup(), - this.properties.getArtifact() == null - ? "unspecified" - : this.properties.getArtifact(), + this.properties.getArtifact() != null + ? this.properties.getArtifact() + : "unspecified", this.properties.getVersion(), this.properties.getName(), this.properties.getTime(), coerceToStringValues( @@ -77,8 +77,8 @@ public class BuildInfo extends ConventionTask { */ @OutputDirectory public File getDestinationDir() { - return this.destinationDir != null ? this.destinationDir - : getProject().getBuildDir(); + return (this.destinationDir != null ? this.destinationDir + : getProject().getBuildDir()); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java index 743804919e..2bfb0bb7ee 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java @@ -54,8 +54,8 @@ public class BootJar extends Jar implements BootArchive { private Action classpathFiles(Spec filter) { return (copySpec) -> copySpec - .from((Callable>) () -> this.classpath == null - ? Collections.emptyList() : this.classpath.filter(filter)); + .from((Callable>) () -> (this.classpath != null + ? this.classpath.filter(filter) : Collections.emptyList())); } @@ -114,7 +114,7 @@ public class BootJar extends Jar implements BootArchive { public void classpath(Object... classpath) { FileCollection existingClasspath = this.classpath; this.classpath = getProject().files( - existingClasspath == null ? Collections.emptyList() : existingClasspath, + existingClasspath != null ? existingClasspath : Collections.emptyList(), classpath); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java index ccd19f4c2c..36c1a61852 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java @@ -51,8 +51,8 @@ public class BootWar extends War implements BootArchive { public BootWar() { getWebInf().into("lib-provided", (copySpec) -> copySpec.from( - (Callable>) () -> this.providedClasspath == null - ? Collections.emptyList() : this.providedClasspath)); + (Callable>) () -> (this.providedClasspath != null + ? this.providedClasspath : Collections.emptyList()))); } @Override @@ -120,7 +120,7 @@ public class BootWar extends War implements BootArchive { public void providedClasspath(Object... classpath) { FileCollection existingClasspath = this.providedClasspath; this.providedClasspath = getProject().files( - existingClasspath == null ? Collections.emptyList() : existingClasspath, + existingClasspath != null ? existingClasspath : Collections.emptyList(), classpath); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index 7df9892815..c2166fd8c5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -284,8 +284,8 @@ class BootZipCopyAction implements CopyAction { } private long getTime(FileCopyDetails details) { - return this.preserveFileTimestamps ? details.getLastModified() - : CONSTANT_TIME_FOR_ZIP_ENTRIES; + return (this.preserveFileTimestamps ? details.getLastModified() + : CONSTANT_TIME_FOR_ZIP_ENTRIES); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java index c2c36451ff..e4f7bc0669 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java @@ -141,7 +141,7 @@ final class AsciiBytes { public boolean matches(CharSequence name, char suffix) { int charIndex = 0; int nameLen = name.length(); - int totalLen = (nameLen + (suffix == 0 ? 0 : 1)); + int totalLen = (nameLen + (suffix != 0 ? 1 : 0)); for (int i = this.offset; i < this.offset + this.length; i++) { int b = this.bytes[i]; int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; @@ -250,7 +250,7 @@ final class AsciiBytes { } public static int hashCode(int hash, char suffix) { - return (suffix == 0 ? hash : (31 * hash + suffix)); + return (suffix != 0 ? (31 * hash + suffix) : hash); } } 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 5d7fe68c73..a66c1ac156 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 @@ -120,7 +120,7 @@ public class JarFile extends java.util.jar.JarFile { parser.addVisitor(centralDirectoryVisitor()); this.data = parser.parse(data, filter == null); this.type = type; - this.manifestSupplier = manifestSupplier != null ? manifestSupplier : () -> { + this.manifestSupplier = (manifestSupplier != null ? manifestSupplier : () -> { try (InputStream inputStream = getInputStream(MANIFEST_NAME)) { if (inputStream == null) { return null; @@ -130,7 +130,7 @@ public class JarFile extends java.util.jar.JarFile { catch (IOException ex) { throw new RuntimeException(ex); } - }; + }); } private CentralDirectoryVisitor centralDirectoryVisitor() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java index 8a6ab4620d..4ef092f9b4 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java @@ -36,7 +36,7 @@ final class StringSequence implements CharSequence { private int hash; StringSequence(String source) { - this(source, 0, (source == null ? -1 : source.length())); + this(source, 0, source != null ? source.length() : -1); } StringSequence(String source, int start, int end) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java index c617375d64..ce4a0b4320 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java @@ -68,7 +68,7 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer private void process(String name, String value) { String existing = this.data.getProperty(name); - this.data.setProperty(name, (existing == null ? value : existing + "," + value)); + this.data.setProperty(name, (existing != null ? existing + "," + value : value)); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java index 2a4e497d3f..247249f572 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java @@ -161,9 +161,9 @@ public class ImageBanner implements Banner { IIOMetadataNode root = (IIOMetadataNode) metadata .getAsTree(metadata.getNativeMetadataFormatName()); IIOMetadataNode extension = findNode(root, "GraphicControlExtension"); - String attribute = (extension == null ? null - : extension.getAttribute("delayTime")); - return (attribute == null ? 0 : Integer.parseInt(attribute) * 10); + String attribute = (extension != null ? extension.getAttribute("delayTime") + : null); + return (attribute != null ? Integer.parseInt(attribute) * 10 : 0); } private static IIOMetadataNode findNode(IIOMetadataNode rootNode, String nodeName) { 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 16c8c0fc0d..e530d7d878 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 @@ -961,8 +961,8 @@ public class SpringApplication { */ @Deprecated public void setWebEnvironment(boolean webEnvironment) { - this.webApplicationType = webEnvironment ? WebApplicationType.SERVLET - : WebApplicationType.NONE; + this.webApplicationType = (webEnvironment ? WebApplicationType.SERVLET + : WebApplicationType.NONE); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java index be1b8ce4c3..fc73b68688 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java @@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements private String getApplicationId(ConfigurableEnvironment environment) { String name = environment.getProperty("spring.application.name"); - return StringUtils.hasText(name) ? name : "application"; + return (StringUtils.hasText(name) ? name : "application"); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index 47155fca8c..44c01cbd55 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -313,8 +313,8 @@ public class ConfigFileApplicationListener Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) { this.environment = environment; - this.resourceLoader = resourceLoader == null ? new DefaultResourceLoader() - : resourceLoader; + this.resourceLoader = (resourceLoader != null ? resourceLoader + : new DefaultResourceLoader()); this.propertySourceLoaders = SpringFactoriesLoader.loadFactories( PropertySourceLoader.class, getClass().getClassLoader()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java index c62621b486..743b72a3cb 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java @@ -98,8 +98,9 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc private void bind(Object bean, String beanName, ConfigurationProperties annotation) { ResolvableType type = getBeanType(bean, beanName); Validated validated = getAnnotation(bean, beanName, Validated.class); - Annotation[] annotations = (validated == null ? new Annotation[] { annotation } - : new Annotation[] { annotation, validated }); + Annotation[] annotations = (validated != null + ? new Annotation[] { annotation, validated } + : new Annotation[] { annotation }); Bindable target = Bindable.of(type).withExistingValue(bean) .withAnnotations(annotations); try { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java index 5c0d1152a1..d5dee53d7a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java @@ -75,8 +75,8 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector { MultiValueMap attributes = metadata .getAllAnnotationAttributes( EnableConfigurationProperties.class.getName(), false); - return collectClasses(attributes == null ? Collections.emptyList() - : attributes.get("value")); + return collectClasses(attributes != null ? attributes.get("value") + : Collections.emptyList()); } private List> collectClasses(List values) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java index 7f293b3f0b..66318da170 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java @@ -77,7 +77,7 @@ public class BindException extends RuntimeException implements OriginProvider { Bindable target) { StringBuilder message = new StringBuilder(); message.append("Failed to bind properties"); - message.append(name == null ? "" : " under '" + name + "'"); + message.append(name != null ? " under '" + name + "'" : ""); message.append(" to ").append(target.getType()); return message.toString(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java index 249c19808f..cf1896a14b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java @@ -89,7 +89,7 @@ public final class BindResult { */ public BindResult map(Function mapper) { Assert.notNull(mapper, "Mapper must not be null"); - return of(this.value == null ? null : mapper.apply(this.value)); + return of(this.value != null ? mapper.apply(this.value) : null); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java index 6e3a0abc13..f66c3d05b8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java @@ -110,7 +110,7 @@ public final class Bindable { public String toString() { ToStringCreator creator = new ToStringCreator(this); creator.append("type", this.type); - creator.append("value", (this.value == null ? "none" : "provided")); + creator.append("value", (this.value != null ? "provided" : "none")); creator.append("annotations", this.annotations); return creator.toString(); } @@ -150,7 +150,7 @@ public final class Bindable { */ public Bindable withAnnotations(Annotation... annotations) { return new Bindable<>(this.type, this.boxedType, this.value, - (annotations == null ? NO_ANNOTATIONS : annotations)); + (annotations != null ? annotations : NO_ANNOTATIONS)); } /** @@ -163,7 +163,7 @@ public final class Bindable { existingValue == null || this.type.isArray() || this.boxedType.resolve().isInstance(existingValue), () -> "ExistingValue must be an instance of " + this.type); - Supplier value = (existingValue == null ? null : () -> existingValue); + Supplier value = (existingValue != null ? () -> existingValue : null); return new Bindable<>(this.type, this.boxedType, value, NO_ANNOTATIONS); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java index 16f8e71379..ad735cf314 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java @@ -40,8 +40,8 @@ class CollectionBinder extends IndexedElementsBinder> { @Override protected Object bindAggregate(ConfigurationPropertyName name, Bindable target, AggregateElementBinder elementBinder) { - Class collectionType = (target.getValue() == null - ? target.getType().resolve(Object.class) : List.class); + Class collectionType = (target.getValue() != null ? List.class + : target.getType().resolve(Object.class)); ResolvableType aggregateType = ResolvableType.forClassWithGenerics(List.class, target.getType().asCollection().getGenerics()); ResolvableType elementType = target.getType().asCollection().getGeneric(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java index d2ef648dd2..d07705c12d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java @@ -100,7 +100,7 @@ abstract class IndexedElementsBinder extends AggregateBinder { source, root); for (int i = 0; i < Integer.MAX_VALUE; i++) { ConfigurationPropertyName name = root - .append(i == 0 ? INDEX_ZERO : "[" + i + "]"); + .append(i != 0 ? "[" + i + "]" : INDEX_ZERO); Object value = elementBinder.bind(name, Bindable.of(elementType), source); if (value == null) { break; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java index c3573e9a2b..6f99796f2d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java @@ -287,7 +287,7 @@ class JavaBeanBinder implements BeanBinder { public Annotation[] getAnnotations() { try { - return (this.field == null ? null : this.field.getDeclaredAnnotations()); + return (this.field != null ? this.field.getDeclaredAnnotations() : null); } catch (Exception ex) { return null; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 5ad55455b4..7efdf055b4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -55,8 +55,8 @@ class MapBinder extends AggregateBinder> { @Override protected Object bindAggregate(ConfigurationPropertyName name, Bindable target, AggregateElementBinder elementBinder) { - Map map = CollectionFactory.createMap((target.getValue() == null - ? target.getType().resolve(Object.class) : Map.class), 0); + Map map = CollectionFactory.createMap((target.getValue() != null + ? Map.class : target.getType().resolve(Object.class)), 0); Bindable resolvedTarget = resolveTarget(target); boolean hasDescendants = getContext().streamSources().anyMatch((source) -> source .containsDescendantOf(name) == ConfigurationPropertyState.PRESENT); @@ -197,7 +197,7 @@ class MapBinder extends AggregateBinder> { StringBuilder result = new StringBuilder(); for (int i = this.root.getNumberOfElements(); i < name .getNumberOfElements(); i++) { - result.append(result.length() == 0 ? "" : "."); + result.append(result.length() != 0 ? "." : ""); result.append(name.getElement(i, Form.ORIGINAL)); } return result.toString(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java index da6dd2113e..df25cdcace 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java @@ -41,7 +41,7 @@ public class IgnoreErrorsBindHandler extends AbstractBindHandler { @Override public Object onFailure(ConfigurationPropertyName name, Bindable target, BindContext context, Exception error) throws Exception { - return (target.getValue() == null ? null : target.getValue().get()); + return (target.getValue() != null ? target.getValue().get() : null); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 2720898291..c5cb44b45f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -131,7 +131,7 @@ public final class ConfigurationPropertyName */ public String getLastElement(Form form) { int size = getNumberOfElements(); - return (size == 0 ? EMPTY_STRING : getElement(size - 1, form)); + return (size != 0 ? getElement(size - 1, form) : EMPTY_STRING); } /** @@ -316,7 +316,7 @@ public final class ConfigurationPropertyName else { for (int i = 0; i < element.length(); i++) { char ch = Character.toLowerCase(element.charAt(i)); - result.append(ch == '_' ? "" : ch); + result.append(ch != '_' ? ch : ""); } } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java index 365fd48872..e91f0f7fe5 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java @@ -42,7 +42,7 @@ class ConfigurationPropertySourcesPropertySource @Override public Object getProperty(String name) { ConfigurationProperty configurationProperty = findConfigurationProperty(name); - return (configurationProperty == null ? null : configurationProperty.getValue()); + return (configurationProperty != null ? configurationProperty.getValue() : null); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java index 41c5ea1255..6b3477a2bc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java @@ -75,7 +75,7 @@ public class MapConfigurationPropertySource * @param value the value */ public void put(Object name, Object value) { - this.source.put((name == null ? null : name.toString()), value); + this.source.put((name != null ? name.toString() : null), value); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java index 4efc5862a1..42a02bfcc1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java @@ -74,7 +74,7 @@ final class CollectionToDelimitedStringConverter implements ConditionalGenericCo Delimiter delimiter = sourceType.getAnnotation(Delimiter.class); return source.stream() .map((element) -> convertElement(element, sourceType, targetType)) - .collect(Collectors.joining(delimiter == null ? "," : delimiter.value())); + .collect(Collectors.joining(delimiter != null ? delimiter.value() : ",")); } private String convertElement(Object element, TypeDescriptor sourceType, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java index cdab8ac834..1cf45f1d53 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java @@ -66,7 +66,7 @@ final class DelimitedStringToArrayConverter implements ConditionalGenericConvert TypeDescriptor targetType) { Delimiter delimiter = targetType.getAnnotation(Delimiter.class); String[] elements = getElements(source, - (delimiter == null ? "," : delimiter.value())); + (delimiter != null ? delimiter.value() : ",")); TypeDescriptor elementDescriptor = targetType.getElementTypeDescriptor(); Object target = Array.newInstance(elementDescriptor.getType(), elements.length); for (int i = 0; i < elements.length; i++) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java index 45589cb613..45a32d9c66 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java @@ -69,7 +69,7 @@ final class DelimitedStringToCollectionConverter implements ConditionalGenericCo TypeDescriptor targetType) { Delimiter delimiter = targetType.getAnnotation(Delimiter.class); String[] elements = getElements(source, - (delimiter == null ? "," : delimiter.value())); + (delimiter != null ? delimiter.value() : ",")); TypeDescriptor elementDescriptor = targetType.getElementTypeDescriptor(); Collection target = createCollection(targetType, elementDescriptor, elements.length); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java index fd587f3f42..b57057929d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java @@ -47,7 +47,7 @@ final class DurationToNumberConverter implements GenericConverter { return null; } DurationUnit unit = sourceType.getAnnotation(DurationUnit.class); - return convert((Duration) source, (unit == null ? null : unit.value()), + return convert((Duration) source, (unit != null ? unit.value() : null), targetType.getObjectType()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java index 425b401d9e..89878ab06c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java @@ -47,8 +47,8 @@ final class DurationToStringConverter implements GenericConverter { } DurationFormat format = sourceType.getAnnotation(DurationFormat.class); DurationUnit unit = sourceType.getAnnotation(DurationUnit.class); - return convert((Duration) source, (format == null ? null : format.value()), - (unit == null ? null : unit.value())); + return convert((Duration) source, (format != null ? format.value() : null), + (unit != null ? unit.value() : null)); } private String convert(Duration source, DurationStyle style, ChronoUnit unit) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java index 7b1578fa9e..9890e9d6f9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java @@ -44,7 +44,7 @@ final class NumberToDurationConverter implements GenericConverter { @Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - return this.delegate.convert(source == null ? null : source.toString(), + return this.delegate.convert(source != null ? source.toString() : null, TypeDescriptor.valueOf(String.class), targetType); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java index dbf8c827bb..265c003e16 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java @@ -49,8 +49,8 @@ final class StringToDurationConverter implements GenericConverter { } DurationFormat format = targetType.getAnnotation(DurationFormat.class); DurationUnit unit = targetType.getAnnotation(DurationUnit.class); - return convert(source.toString(), (format == null ? null : format.value()), - (unit == null ? null : unit.value())); + return convert(source.toString(), (format != null ? format.value() : null), + (unit != null ? unit.value() : null)); } private Duration convert(String source, DurationStyle style, ChronoUnit unit) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java index 1a2c524ac8..b58b1aeee1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java @@ -74,8 +74,8 @@ class InvalidConfigurationPropertyValueFailureAnalyzer } private Stream> getPropertySources() { - Iterable> sources = (this.environment == null - ? Collections.emptyList() : this.environment.getPropertySources()); + Iterable> sources = (this.environment != null + ? this.environment.getPropertySources() : Collections.emptyList()); return StreamSupport.stream(sources.spliterator(), false) .filter((source) -> !ConfigurationPropertySources .isAttachedConfigurationPropertySource(source)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java index 7cb0b418f9..336d5dbd6b 100755 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java @@ -54,7 +54,7 @@ public class YamlPropertySourceLoader implements PropertySourceLoader { List> propertySources = new ArrayList<>(loaded.size()); for (int i = 0; i < loaded.size(); i++) { propertySources.add(new OriginTrackedMapPropertySource( - name + (loaded.size() == 1 ? "" : " (document #" + i + ")"), + name + (loaded.size() != 1 ? " (document #" + i + ")" : ""), loaded.get(i))); } return propertySources; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java index f20da6cba8..99716bdd59 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java @@ -138,8 +138,8 @@ public final class DataSourceBuilder { } private Class getType() { - Class type = this.type != null ? this.type - : findType(this.classLoader); + Class type = (this.type != null ? this.type + : findType(this.classLoader)); if (type != null) { return type; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java index 830d398673..c8b1dc8064 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java @@ -44,7 +44,7 @@ public abstract class AbstractJsonParser implements JsonParser { protected final T trimParse(String json, String prefix, Function parser) { - String trimmed = (json == null ? "" : json.trim()); + String trimmed = (json != null ? json.trim() : ""); if (trimmed.startsWith(prefix)) { return parser.apply(trimmed); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java index 7b814fa273..cbafdc5046 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java @@ -53,7 +53,7 @@ public class OriginTrackedValue implements OriginProvider { @Override public String toString() { - return (this.value == null ? null : this.value.toString()); + return (this.value != null ? this.value.toString() : null); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java index 49b2428571..0a2e189eb8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java @@ -83,8 +83,8 @@ public class TextResourceOrigin implements Origin { @Override public String toString() { StringBuilder result = new StringBuilder(); - result.append(this.resource == null ? "unknown resource [?]" - : this.resource.getDescription()); + result.append(this.resource != null ? this.resource.getDescription() + : "unknown resource [?]"); if (this.location != null) { result.append(":").append(this.location); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java index ad4cf2e092..9f1af2d5c3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java @@ -49,8 +49,9 @@ public final class LambdaSafe { static { CLASS_GET_MODULE = ReflectionUtils.findMethod(Class.class, "getModule"); - MODULE_GET_NAME = (CLASS_GET_MODULE == null ? null : ReflectionUtils - .findMethod(CLASS_GET_MODULE.getReturnType(), "getName")); + MODULE_GET_NAME = (CLASS_GET_MODULE != null + ? ReflectionUtils.findMethod(CLASS_GET_MODULE.getReturnType(), "getName") + : null); } private LambdaSafe() { @@ -77,8 +78,8 @@ public final class LambdaSafe { } /** - * Start a call to callback instances, dealing with common generic type - * concerns and exceptions. + * Start a call to callback instances, dealing with common generic type concerns and + * exceptions. * @param callbackType the callback type (a {@link FunctionalInterface functional * interface}) * @param callbackInstances the callback instances (elements may be lambdas) @@ -141,9 +142,9 @@ public final class LambdaSafe { } /** - * Use a specific filter to determine when a callback should apply. If no - * explicit filter is set filter will be attempted using the generic type on the - * callback type. + * Use a specific filter to determine when a callback should apply. If no explicit + * filter is set filter will be attempted using the generic type on the callback + * type. * @param filter the filter to use * @return this instance */ @@ -205,9 +206,8 @@ public final class LambdaSafe { if (this.logger.isDebugEnabled()) { Class expectedType = ResolvableType.forClass(this.callbackType) .resolveGeneric(); - String message = "Non-matching " - + (expectedType == null ? "type" - : ClassUtils.getShortName(expectedType) + " type") + String message = "Non-matching " + (expectedType != null + ? ClassUtils.getShortName(expectedType) + " type" : "type") + " for callback " + ClassUtils.getShortName(this.callbackType) + ": " + callback; this.logger.debug(message, ex); @@ -403,7 +403,7 @@ public final class LambdaSafe { * @return the result of the invocation or the fallback */ public R get(R fallback) { - return (this == NONE ? fallback : this.value); + return (this != NONE ? this.value : fallback); } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index 1fdc54cca8..4351a6359e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -252,7 +252,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor private File getTempDirectory() { String temp = System.getProperty("java.io.tmpdir"); - return (temp == null ? null : new File(temp)); + return (temp != null ? new File(temp) : null); } private void configureDocumentRoot(WebAppContext handler) { @@ -260,11 +260,11 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor File docBase = (root != null ? root : createTempDir("jetty-docbase")); try { List resources = new ArrayList<>(); - Resource rootResource = docBase.isDirectory() + Resource rootResource = (docBase.isDirectory() ? Resource.newResource(docBase.getCanonicalFile()) - : JarResource.newJarResource(Resource.newResource(docBase)); + : JarResource.newJarResource(Resource.newResource(docBase))); resources.add( - root == null ? rootResource : new LoaderHidingResource(rootResource)); + root != null ? new LoaderHidingResource(rootResource) : rootResource); for (URL resourceJarUrl : this.getUrlsOfJarsWithMetaInfResources()) { Resource resource = createResource(resourceJarUrl); if (resource.exists() && resource.isDirectory()) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java index 929fa29f31..abe648b156 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java @@ -126,13 +126,13 @@ public class SslServerCustomizer implements NettyServerCustomizer { private KeyStore loadKeyStore(String type, String resource, String password) throws Exception { - type = (type == null ? "JKS" : type); + type = (type != null ? type : "JKS"); if (resource == null) { return null; } KeyStore store = KeyStore.getInstance(type); URL url = ResourceUtils.getURL(resource); - store.load(url.openStream(), password == null ? null : password.toCharArray()); + store.load(url.openStream(), password != null ? password.toCharArray() : null); return store; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java index 3aaa311f45..eb0cbdbdad 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java @@ -175,13 +175,13 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { private KeyStore loadKeyStore(String type, String resource, String password) throws Exception { - type = (type == null ? "JKS" : type); + type = (type != null ? type : "JKS"); if (resource == null) { return null; } KeyStore store = KeyStore.getInstance(type); URL url = ResourceUtils.getURL(resource); - store.load(url.openStream(), password == null ? null : password.toCharArray()); + store.load(url.openStream(), password != null ? password.toCharArray() : null); return store; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java index 9ce8028b76..7fa41b62e8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java @@ -150,8 +150,8 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF 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()); } 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 46aa264046..15707be1fc 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 @@ -387,7 +387,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac private File getCanonicalDocumentRoot(File docBase) { try { - File root = docBase != null ? docBase : createTempDir("undertow-docbase"); + File root = (docBase != null ? docBase : createTempDir("undertow-docbase")); return root.getCanonicalFile(); } catch (IOException ex) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java index cff2575a84..2efdf609cc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java @@ -167,8 +167,8 @@ public class UndertowWebServer implements WebServer { private UndertowWebServer.Port getPortFromChannel(BoundChannel channel) { SocketAddress socketAddress = channel.getLocalAddress(); if (socketAddress instanceof InetSocketAddress) { - String protocol = ReflectionUtils.findField(channel.getClass(), "ssl") != null - ? "https" : "http"; + Field sslField = ReflectionUtils.findField(channel.getClass(), "ssl"); + String protocol = (sslField != null ? "https" : "http"); return new UndertowWebServer.Port( ((InetSocketAddress) socketAddress).getPort(), protocol); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java index 857568012c..b33934ca29 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java @@ -106,7 +106,7 @@ public class DefaultErrorAttributes implements ErrorAttributes { private Throwable determineException(Throwable error) { if (error instanceof ResponseStatusException) { - return error.getCause() != null ? error.getCause() : error; + return (error.getCause() != null ? error.getCause() : error); } return error; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java index 7107b8a313..f79dc58dee 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java @@ -98,7 +98,7 @@ class DocumentRoot { File getCodeSourceArchive(CodeSource codeSource) { try { - URL location = (codeSource == null ? null : codeSource.getLocation()); + URL location = (codeSource != null ? codeSource.getLocation() : null); if (location == null) { return null; } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java index da563758c5..b135faaf26 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java @@ -114,7 +114,7 @@ public class AliasedConfigurationPropertySourceTests { private Object getValue(ConfigurationPropertySource source, String name) { ConfigurationProperty property = source .getConfigurationProperty(ConfigurationPropertyName.of(name)); - return (property == null ? null : property.getValue()); + return (property != null ? property.getValue() : null); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java index db0027ba97..e1c238ce3b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java @@ -112,7 +112,7 @@ public class MapConfigurationPropertySourceTests { private Object getValue(ConfigurationPropertySource source, String name) { ConfigurationProperty property = source .getConfigurationProperty(ConfigurationPropertyName.of(name)); - return (property == null ? null : property.getValue()); + return (property != null ? property.getValue() : null); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java index 3905a63e2c..f503bcdd6e 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java @@ -249,7 +249,7 @@ public class OriginTrackedPropertiesLoaderTests { } private Object getValue(OriginTrackedValue value) { - return (value == null ? null : value.getValue()); + return (value != null ? value.getValue() : null); } private String getLocation(OriginTrackedValue value) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java index 7f81298e75..90b343f9ee 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java @@ -54,7 +54,7 @@ public final class MockOrigin implements Origin { } public static Origin of(String value) { - return (value == null ? null : new MockOrigin(value)); + return (value != null ? new MockOrigin(value) : null); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java index 50ba1f8a48..2cb9b4381b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java @@ -321,7 +321,7 @@ public class JettyServletWebServerFactoryTests WebAppContext context = (WebAppContext) ((JettyWebServer) this.webServer) .getServer().getHandler(); String charsetName = context.getLocaleEncoding(locale); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } @Override diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index dcd6b4d10d..761fd68ad5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -88,7 +88,8 @@ public class TomcatServletWebServerFactoryTests @After public void restoreTccl() { - ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", null); + ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", + null); ReflectionTestUtils.setField(URL.class, "factory", null); Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); } @@ -446,7 +447,7 @@ public class TomcatServletWebServerFactoryTests .getHost().findChildren()[0]; CharsetMapper mapper = ((TomcatEmbeddedContext) context).getCharsetMapper(); String charsetName = mapper.getCharset(locale); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } private void assertTimeout(TomcatServletWebServerFactory factory, int expected) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java index a6cb6a05aa..cc48f35730 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java @@ -50,15 +50,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return getWebServer() == null ? null : getWebServer().getServletContext(); + return (getWebServer() != null ? getWebServer().getServletContext() : null); } public RegisteredServlet getRegisteredServlet(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredServlet(index); + return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) + : null); } public RegisteredFilter getRegisteredFilter(int index) { - return getWebServer() == null ? null : getWebServer().getRegisteredFilters(index); + return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) + : null); } public static class MockServletWebServer