Skip to content

Commit 97a771c

Browse files
committed
Adapt to new Placeholder resolution API
1 parent a984342 commit 97a771c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private boolean hasDataSourceUrlProperty(ConditionContext context) {
157157
return StringUtils.hasText(environment.getProperty(DATASOURCE_URL_PROPERTY));
158158
}
159159
catch (IllegalArgumentException ex) {
160+
// NOTE: This should be PlaceholderResolutionException
160161
// Ignore unresolvable placeholder errors
161162
}
162163
}

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/SpringBootTestRandomPortEnvironmentPostProcessorTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void postProcessWhenManagementServerPortPlaceholderAbsentShouldFail() {
169169
addTestPropertySource("0", null);
170170
this.propertySources
171171
.addLast(new MapPropertySource("other", Collections.singletonMap("management.server.port", "${port}")));
172+
// NOTE: This should be PlaceholderResolutionException
172173
assertThatIllegalArgumentException()
173174
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
174175
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");
@@ -196,6 +197,7 @@ void postProcessWhenServerPortPlaceholderAbsentShouldFail() {
196197
source.put("server.port", "${port}");
197198
source.put("management.server.port", "9090");
198199
this.propertySources.addLast(new MapPropertySource("other", source));
200+
// NOTE: This should be PlaceholderResolutionException
199201
assertThatIllegalArgumentException()
200202
.isThrownBy(() -> this.postProcessor.postProcessEnvironment(this.environment, null))
201203
.withMessage("Could not resolve placeholder 'port' in value \"${port}\"");

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataEnvironmentContributorPlaceholdersResolver.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class ConfigDataEnvironmentContributorPlaceholdersResolver implements Placeholde
5656
this.failOnResolveFromInactiveContributor = failOnResolveFromInactiveContributor;
5757
this.conversionService = conversionService;
5858
this.helper = new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
59-
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR, true);
59+
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
60+
SystemPropertyUtils.ESCAPE_CHARACTER, true);
6061
}
6162

6263
@Override

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,8 +47,10 @@ public PropertySourcesPlaceholdersResolver(Iterable<PropertySource<?>> sources)
4747

4848
public PropertySourcesPlaceholdersResolver(Iterable<PropertySource<?>> sources, PropertyPlaceholderHelper helper) {
4949
this.sources = sources;
50-
this.helper = (helper != null) ? helper : new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
51-
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR, true);
50+
this.helper = (helper != null) ? helper
51+
: new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
52+
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
53+
SystemPropertyUtils.ESCAPE_CHARACTER, true);
5254
}
5355

5456
@Override

0 commit comments

Comments
 (0)