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 e4c0b5465c81..3ec362e0fee5 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 @@ -59,8 +59,8 @@ public void customize(TransactionManager transactionManager) { * @since 3.2.0 */ public static TransactionManagerCustomizers of(Collection> customizers) { - return new TransactionManagerCustomizers((customizers != null) ? new ArrayList<>(customizers) - : Collections.>emptyList()); + return new TransactionManagerCustomizers( + (customizers != null) ? new ArrayList<>(customizers) : Collections.emptyList()); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath.java index 302099298c1e..a904ffbf1978 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPath.java @@ -74,7 +74,7 @@ default String getPrefix() { * @return the path as a servlet URL mapping */ default String getServletUrlMapping() { - if (getPath().equals("") || getPath().equals("/")) { + if (getPath().isEmpty() || getPath().equals("/")) { return "/"; } if (getPath().contains("*")) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java index 673dcee7aef5..53d6bbfdd1af 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java @@ -237,7 +237,7 @@ public void setLoadOnStartup(int loadOnStartup) { } public String getServletMapping() { - if (this.path.equals("") || this.path.equals("/")) { + if (this.path.isEmpty() || this.path.equals("/")) { return "/"; } if (this.path.endsWith("/")) { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java index 2c6c3ebe4719..cc59cbf970a4 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/jdbc/TestDatabaseAutoConfiguration.java @@ -214,7 +214,7 @@ private boolean isUsingTestDatasourceUrl() { List bound = new ArrayList<>(); Binder.get(this.environment, new BoundPropertiesTrackingBindHandler(bound::add)) .bind(DATASOURCE_URL_PROPERTY, BINDABLE_STRING); - return (!bound.isEmpty()) ? isUsingTestDatasourceUrl(bound.get(0)) : false; + return !bound.isEmpty() && isUsingTestDatasourceUrl(bound.get(0)); } private boolean isUsingTestDatasourceUrl(ConfigurationProperty configurationProperty) { 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 9d6ee1866fde..e44bd5e54f60 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 @@ -303,7 +303,7 @@ private void processEndpoint(AnnotationMirror annotation, TypeElement element) { boolean enabledByDefaultAttribute = (boolean) elementValues.getOrDefault("enableByDefault", true); String defaultAccess = (!enabledByDefaultAttribute) ? "none" : (elementValues.getOrDefault("defaultAccess", "unrestricted").toString()).toLowerCase(Locale.ENGLISH); - boolean enabledByDefault = "none".equals(defaultAccess) ? false : enabledByDefaultAttribute; + boolean enabledByDefault = !"none".equals(defaultAccess) && enabledByDefaultAttribute; String type = this.metadataEnv.getTypeUtils().getQualifiedName(element); this.metadataCollector.addIfAbsent(ItemMetadata.newGroup(endpointKey, type, type, null)); ItemMetadata accessProperty = ItemMetadata.newProperty(endpointKey, "access", endpointAccessEnum(), type, null, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringEnvironmentPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringEnvironmentPropertySource.java index 8e521c62477e..eb0dd5d84311 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringEnvironmentPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/SpringEnvironmentPropertySource.java @@ -48,7 +48,7 @@ public String getProperty(String key) { @Override public boolean containsProperty(String key) { Environment environment = this.environment; - return (environment != null) ? environment.containsProperty(key) : false; + return environment != null && environment.containsProperty(key); } void setEnvironment(Environment environment) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index 3dc03e97ab19..8792803e78ec 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -416,7 +416,7 @@ private String getContextPath() { .map(TomcatEmbeddedContext.class::cast) .filter(this::imperative) .map(TomcatEmbeddedContext::getPath) - .map((path) -> path.equals("") ? "/" : path) + .map((path) -> path.isEmpty() ? "/" : path) .collect(Collectors.joining(" ")); return StringUtils.hasText(contextPath) ? contextPath : null; }