From 133ecab3cf5d0e2d5678340feeea231470e5f200 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 21 Feb 2025 20:29:47 +0900 Subject: [PATCH 1/2] Replace unconventional Optional usages See gh-44393 Signed-off-by: Johnny Lim --- .../boot/autoconfigure/amqp/RabbitProperties.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 1510e9adbed..7dd84a7957e 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.Duration; 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 class RabbitProperties { 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 class RabbitProperties { 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 class RabbitProperties { * @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; } From 56bd551ce93cb5341f556ffd895fd1037deed7f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Sat, 22 Feb 2025 18:43:30 +0100 Subject: [PATCH 2/2] Update copyright year of changed file See gh-44393 --- .../boot/autoconfigure/amqp/RabbitProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7dd84a7957e..5d63ff2c858 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2024 the original author or authors. + * Copyright 2012-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.