Treat empty SSL bundle as unset

Update the Cassandra, Redis, and MongoDB SSL configuration so that an
empty `bundle` property is treated as unset rather than enabling SSL.

See gh-50624

Signed-off-by: Lee JiWon <dlwldnjs1009@gmail.com>
This commit is contained in:
Lee JiWon
2026-05-30 16:11:05 +02:00
committed by Stéphane Nicoll
parent 8288b8fc36
commit 39ed20b474
6 changed files with 27 additions and 3 deletions
@@ -23,6 +23,7 @@ import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;
/**
* Configuration properties for Cassandra.
@@ -236,7 +237,7 @@ public class CassandraProperties {
private String bundle;
public boolean isEnabled() {
return (this.enabled != null) ? this.enabled : this.bundle != null;
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
}
public void setEnabled(boolean enabled) {
@@ -20,6 +20,7 @@ import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
/**
* Configuration properties for Redis.
@@ -425,7 +426,7 @@ public class RedisProperties {
private String bundle;
public boolean isEnabled() {
return (this.enabled != null) ? this.enabled : this.bundle != null;
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
}
public void setEnabled(boolean enabled) {
@@ -22,6 +22,7 @@ import com.mongodb.ConnectionString;
import org.bson.UuidRepresentation;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
/**
* Configuration properties for Mongo.
@@ -289,7 +290,7 @@ public class MongoProperties {
private String bundle;
public boolean isEnabled() {
return (this.enabled != null) ? this.enabled : this.bundle != null;
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
}
public void setEnabled(boolean enabled) {
@@ -58,4 +58,11 @@ class CassandraPropertiesTests {
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
}
@Test
void sslIsNotEnabledWhenBundleIsEmpty() {
CassandraProperties properties = new CassandraProperties();
properties.getSsl().setBundle("");
assertThat(properties.getSsl().isEnabled()).isFalse();
}
}
@@ -39,4 +39,11 @@ class RedisPropertiesTests {
.isEqualTo(defaultClusterTopologyRefreshOptions.useDynamicRefreshSources());
}
@Test
void sslIsNotEnabledWhenBundleIsEmpty() {
RedisProperties properties = new RedisProperties();
properties.getSsl().setBundle("");
assertThat(properties.getSsl().isEnabled()).isFalse();
}
}
@@ -37,6 +37,13 @@ class MongoPropertiesTests {
assertThat(springBootDefault).isEqualTo(springDataDefault);
}
@Test
void sslIsNotEnabledWhenBundleIsEmpty() {
MongoProperties properties = new MongoProperties();
properties.getSsl().setBundle("");
assertThat(properties.getSsl().isEnabled()).isFalse();
}
private UuidRepresentation springDataDefaultUuidRepresentation() {
return new MongoConfigurationSupport() {