Skip to content

Commit 4aac37c

Browse files
committed
Merge branch '3.5.x' into 4.0.x
Closes gh-50634
2 parents 326181c + a009ea4 commit 4aac37c

8 files changed

Lines changed: 44 additions & 5 deletions

File tree

module/spring-boot-cassandra/src/main/java/org/springframework/boot/cassandra/autoconfigure/CassandraProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import org.springframework.boot.context.properties.ConfigurationProperties;
2626
import org.springframework.core.io.Resource;
27+
import org.springframework.util.StringUtils;
2728

2829
/**
2930
* Configuration properties for Cassandra.
@@ -237,7 +238,7 @@ public static class Ssl {
237238
private @Nullable String bundle;
238239

239240
public boolean isEnabled() {
240-
return (this.enabled != null) ? this.enabled : this.bundle != null;
241+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
241242
}
242243

243244
public void setEnabled(boolean enabled) {

module/spring-boot-cassandra/src/test/java/org/springframework/boot/cassandra/autoconfigure/CassandraPropertiesTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,11 @@ void defaultValuesInManualMetadataAreConsistent() {
5858
assertThat(driverDefaults.get(TypedDriverOption.HEARTBEAT_TIMEOUT)).isEqualTo(Duration.ofSeconds(5));
5959
}
6060

61+
@Test
62+
void sslIsNotEnabledWhenBundleIsEmpty() {
63+
CassandraProperties properties = new CassandraProperties();
64+
properties.getSsl().setBundle("");
65+
assertThat(properties.getSsl().isEnabled()).isFalse();
66+
}
67+
6168
}

module/spring-boot-data-redis/src/main/java/org/springframework/boot/data/redis/autoconfigure/DataRedisProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.jspecify.annotations.Nullable;
2323

2424
import org.springframework.boot.context.properties.ConfigurationProperties;
25+
import org.springframework.util.StringUtils;
2526

2627
/**
2728
* Configuration properties for Redis.
@@ -457,7 +458,7 @@ public static class Ssl {
457458
private @Nullable String bundle;
458459

459460
public boolean isEnabled() {
460-
return (this.enabled != null) ? this.enabled : this.bundle != null;
461+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
461462
}
462463

463464
public void setEnabled(boolean enabled) {

module/spring-boot-data-redis/src/test/java/org/springframework/boot/data/redis/autoconfigure/RedisPropertiesTests.java renamed to module/spring-boot-data-redis/src/test/java/org/springframework/boot/data/redis/autoconfigure/DataRedisPropertiesTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author Stephane Nicoll
3030
*/
31-
class RedisPropertiesTests {
31+
class DataRedisPropertiesTests {
3232

3333
@Test
3434
void lettuceDefaultsAreConsistent() {
@@ -39,4 +39,11 @@ void lettuceDefaultsAreConsistent() {
3939
.isEqualTo(defaultClusterTopologyRefreshOptions.useDynamicRefreshSources());
4040
}
4141

42+
@Test
43+
void sslIsNotEnabledWhenBundleIsEmpty() {
44+
DataRedisProperties properties = new DataRedisProperties();
45+
properties.getSsl().setBundle("");
46+
assertThat(properties.getSsl().isEnabled()).isFalse();
47+
}
48+
4249
}

module/spring-boot-mail/src/main/java/org/springframework/boot/mail/autoconfigure/MailSenderPropertiesConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private void applyProperties(MailProperties properties, JavaMailSenderImpl sende
7373
if (ssl.isEnabled()) {
7474
javaMailProperties.setProperty("mail." + protocol + ".ssl.enable", "true");
7575
}
76-
if (ssl.getBundle() != null) {
76+
if (StringUtils.hasLength(ssl.getBundle())) {
7777
Assert.state(sslBundles != null, "'sslBundles' must not be null");
7878
SslBundle sslBundle = sslBundles.getBundle(ssl.getBundle());
7979
javaMailProperties.put("mail." + protocol + ".ssl.socketFactory",

module/spring-boot-mail/src/test/java/org/springframework/boot/mail/autoconfigure/MailSenderAutoConfigurationTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,21 @@ void connectionOnStartupNotCalled() {
245245
});
246246
}
247247

248+
@Test
249+
@WithPackageResources("test.jks")
250+
void sslIsNotEnabledWhenBundleIsEmpty() {
251+
this.contextRunner
252+
.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.bundle: ",
253+
"spring.ssl.bundle.jks.test-bundle.keystore.location:classpath:test.jks",
254+
"spring.ssl.bundle.jks.test-bundle.keystore.password:secret",
255+
"spring.ssl.bundle.jks.test-bundle.key.password:password")
256+
.run((context) -> {
257+
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
258+
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
259+
assertThat(mailSender.getJavaMailProperties().get("mail.smtp.ssl.socketFactory")).isNull();
260+
});
261+
}
262+
248263
@Test
249264
void smtpSslEnabled() {
250265
this.contextRunner.withPropertyValues("spring.mail.host:localhost", "spring.mail.ssl.enabled:true")

module/spring-boot-mongodb/src/main/java/org/springframework/boot/mongodb/autoconfigure/MongoProperties.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.jspecify.annotations.Nullable;
2424

2525
import org.springframework.boot.context.properties.ConfigurationProperties;
26+
import org.springframework.util.StringUtils;
2627

2728
/**
2829
* Configuration properties for Mongo.
@@ -238,7 +239,7 @@ public static class Ssl {
238239
private @Nullable String bundle;
239240

240241
public boolean isEnabled() {
241-
return (this.enabled != null) ? this.enabled : this.bundle != null;
242+
return (this.enabled != null) ? this.enabled : StringUtils.hasText(this.bundle);
242243
}
243244

244245
public void setEnabled(boolean enabled) {

module/spring-boot-mongodb/src/test/java/org/springframework/boot/mongodb/autoconfigure/MongoPropertiesTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ void canBindCharArrayPassword() {
4949
});
5050
}
5151

52+
@Test
53+
void sslIsNotEnabledWhenBundleIsEmpty() {
54+
MongoProperties properties = new MongoProperties();
55+
properties.getSsl().setBundle("");
56+
assertThat(properties.getSsl().isEnabled()).isFalse();
57+
}
58+
5259
private UuidRepresentation springDataDefaultUuidRepresentation() {
5360
return new MongoConfigurationSupport() {
5461

0 commit comments

Comments
 (0)