diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
index ff3ec81253..17edff7565 100644
--- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
+++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java
@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.amqp;
import java.time.Duration;
import java.util.List;
-import java.util.Objects;
import com.rabbitmq.client.Channel;
@@ -42,7 +41,6 @@ import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
-import org.springframework.util.ReflectionUtils;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link RabbitTemplate}.
@@ -93,11 +91,6 @@ public class RabbitAutoConfiguration {
@ConditionalOnMissingBean(ConnectionFactory.class)
protected static class RabbitConnectionFactoryCreator {
- // Only available in rabbitmq-java-client 5.4.0 +
- private static final boolean CAN_ENABLE_HOSTNAME_VERIFICATION = ReflectionUtils
- .findMethod(com.rabbitmq.client.ConnectionFactory.class,
- "enableHostnameVerification") != null;
-
@Bean
public CachingConnectionFactory rabbitConnectionFactory(
RabbitProperties properties,
@@ -149,11 +142,8 @@ public class RabbitAutoConfiguration {
map.from(ssl::getTrustStorePassword).to(factory::setTrustStorePassphrase);
map.from(ssl::isValidateServerCertificate).to((validate) -> factory
.setSkipServerCertificateValidation(!validate));
- map.from(ssl::getVerifyHostname).when(Objects::nonNull)
+ map.from(ssl::getVerifyHostname)
.to(factory::setEnableHostnameVerification);
- if (ssl.getVerifyHostname() == null && CAN_ENABLE_HOSTNAME_VERIFICATION) {
- factory.setEnableHostnameVerification(true);
- }
}
map.from(properties::getConnectionTimeout).whenNonNull()
.asInt(Duration::toMillis).to(factory::setConnectionTimeout);
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 44a9157f3a..1a6cc3ffee 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
@@ -356,10 +356,9 @@ public class RabbitProperties {
private boolean validateServerCertificate = true;
/**
- * Whether to enable hostname verification. Requires AMQP client 4.8 or above and
- * defaults to true when a suitable client version is used.
+ * Whether to enable hostname verification.
*/
- private Boolean verifyHostname;
+ private boolean verifyHostname = true;
public boolean isEnabled() {
return this.enabled;
@@ -433,11 +432,11 @@ public class RabbitProperties {
this.validateServerCertificate = validateServerCertificate;
}
- public Boolean getVerifyHostname() {
+ public boolean getVerifyHostname() {
return this.verifyHostname;
}
- public void setVerifyHostname(Boolean verifyHostname) {
+ public void setVerifyHostname(boolean verifyHostname) {
this.verifyHostname = verifyHostname;
}
diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml
index 5a9c101c4e..3539d84ced 100644
--- a/spring-boot-project/spring-boot-dependencies/pom.xml
+++ b/spring-boot-project/spring-boot-dependencies/pom.xml
@@ -141,7 +141,7 @@
42.2.4
2.3.0
4.2.1
- 5.3.0
+ 5.4.0
Californium-M2
3.1.1
1.0.2
diff --git a/spring-boot-samples/spring-boot-sample-amqp/pom.xml b/spring-boot-samples/spring-boot-sample-amqp/pom.xml
index c6a66a6100..ab7de9b2a4 100644
--- a/spring-boot-samples/spring-boot-sample-amqp/pom.xml
+++ b/spring-boot-samples/spring-boot-sample-amqp/pom.xml
@@ -14,7 +14,6 @@
Spring Boot AMQP Sample
${basedir}/../..
- 5.4.0