diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index f9a8af565e61..0b0b89a6a513 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -20,7 +20,6 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import org.springframework.amqp.core.AcknowledgeMode; import org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.AddressShuffleMode; @@ -194,7 +193,7 @@ public int determinePort() { if (port != null) { return port; } - return (Optional.ofNullable(getSsl().getEnabled()).orElse(false)) ? DEFAULT_PORT_SECURE : DEFAULT_PORT; + return Boolean.TRUE.equals(getSsl().getEnabled()) ? DEFAULT_PORT_SECURE : DEFAULT_PORT; } return this.parsedAddresses.get(0).port; } @@ -235,7 +234,7 @@ public void setAddresses(List addresses) { private List
parseAddresses(List addresses) { List
parsedAddresses = new ArrayList<>(); for (String address : addresses) { - parsedAddresses.add(new Address(address, Optional.ofNullable(getSsl().getEnabled()).orElse(false))); + parsedAddresses.add(new Address(address, Boolean.TRUE.equals(getSsl().getEnabled()))); } return parsedAddresses; } @@ -475,7 +474,7 @@ public Boolean getEnabled() { * @see #getEnabled() () */ public boolean determineEnabled() { - boolean defaultEnabled = Optional.ofNullable(getEnabled()).orElse(false) || this.bundle != null; + boolean defaultEnabled = Boolean.TRUE.equals(getEnabled()) || this.bundle != null; if (CollectionUtils.isEmpty(RabbitProperties.this.parsedAddresses)) { return defaultEnabled; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesBeanFactoryInitializationAotProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesBeanFactoryInitializationAotProcessor.java index 946fc2c6116f..3d23ebc7606e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesBeanFactoryInitializationAotProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/structured/StructuredLoggingJsonPropertiesBeanFactoryInitializationAotProcessor.java @@ -16,7 +16,6 @@ package org.springframework.boot.logging.structured; -import java.util.Optional; import java.util.Set; import org.springframework.aot.generate.GenerationContext; @@ -58,10 +57,8 @@ public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableL } private static String getCustomStackTracePrinter(StructuredLoggingJsonProperties properties) { - return Optional.ofNullable(properties.stackTrace()) - .filter(StackTrace::hasCustomPrinter) - .map(StackTrace::printer) - .orElse(null); + StackTrace stackTrace = properties.stackTrace(); + return (stackTrace != null && stackTrace.hasCustomPrinter()) ? stackTrace.printer() : null; } private static final class AotContribution implements BeanFactoryInitializationAotContribution {