From bb0ec34e7b73883cb980fd0dedc626049469d429 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 28 Mar 2023 14:28:16 +0100 Subject: [PATCH] Resolve placeholders in reference config against all other config Fixes gh-34643 --- .../cassandra/CassandraAutoConfiguration.java | 2 +- .../cassandra/CassandraAutoConfigurationTests.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java index 1acd74ca42..5ea0543d70 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java @@ -149,7 +149,7 @@ public class CassandraAutoConfiguration { config = config.withFallback(loadConfig(this.properties.getConfig())); } config = config.withFallback(SPRING_BOOT_DEFAULTS); - config = config.withFallback(ConfigFactory.defaultReference()); + config = config.withFallback(ConfigFactory.defaultReferenceUnresolved()); return config.resolve(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java index 8369789dc0..e1c1c5edc6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfigurationTests.java @@ -322,6 +322,18 @@ class CassandraAutoConfigurationTests { }); } + @Test + void placeholdersInReferenceConfAreResolvedAgainstConfigDerivedFromSpringCassandraProperties() { + this.contextRunner.withPropertyValues("spring.cassandra.request.timeout=60s").run((context) -> { + DriverExecutionProfile actual = context.getBean(DriverConfigLoader.class) + .getInitialConfig() + .getDefaultProfile(); + assertThat(actual.getDuration(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofSeconds(60)); + assertThat(actual.getDuration(DefaultDriverOption.METADATA_SCHEMA_REQUEST_TIMEOUT)) + .isEqualTo(Duration.ofSeconds(60)); + }); + } + @Test void driverConfigLoaderWithConfigCreateProfiles() { String configLocation = "org/springframework/boot/autoconfigure/cassandra/profiles.conf";