From c9e69b13b1f916e9af483ac3f1caeac3411accfd 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 580ce8a5e352..9a6d90b9e90f 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 @@ -136,7 +136,7 @@ private Config cassandraConfiguration(CassandraProperties properties) { config = config.withFallback(loadConfig(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 ebb87e8b2581..a94395cfeaf6 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 @@ -300,6 +300,18 @@ void driverConfigLoaderWithConfigOverridesDefaults() { }); } + @Test + void placeholdersInReferenceConfAreResolvedAgainstConfigDerivedFromSpringCassandraProperties() { + this.contextRunner.withPropertyValues("spring.data.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";