Skip to content

Commit ea4e7df

Browse files
committed
Consistently declare ignoreUnresolvablePlaceholders as last argument
1 parent 7c07c43 commit ea4e7df

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private class PlaceholderResolvingStringValueResolver implements StringValueReso
235235
public PlaceholderResolvingStringValueResolver(Properties props) {
236236
this.helper = new PropertyPlaceholderHelper(
237237
placeholderPrefix, placeholderSuffix, valueSeparator,
238-
ignoreUnresolvablePlaceholders, escapeCharacter);
238+
escapeCharacter, ignoreUnresolvablePlaceholders);
239239
this.resolver = new PropertyPlaceholderConfigurerResolver(props);
240240
}
241241

spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ protected String resolveNestedPlaceholders(String value) {
248248

249249
private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) {
250250
return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix,
251-
this.valueSeparator, ignoreUnresolvablePlaceholders, this.escapeCharacter);
251+
this.valueSeparator, this.escapeCharacter, ignoreUnresolvablePlaceholders);
252252
}
253253

254254
private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) {

spring-core/src/main/java/org/springframework/util/PlaceholderParser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ final class PlaceholderParser {
8989
* Create an instance using the specified input for the parser.
9090
* @param prefix the prefix that denotes the start of a placeholder
9191
* @param suffix the suffix that denotes the end of a placeholder
92-
* @param ignoreUnresolvablePlaceholders whether unresolvable placeholders
93-
* should be ignored ({@code true}) or cause an exception ({@code false})
9492
* @param separator the separating character between the placeholder
9593
* variable and the associated default value, if any
9694
* @param escape the character to use at the beginning of a placeholder
9795
* prefix or separator to escape it and render it as is
96+
* @param ignoreUnresolvablePlaceholders whether unresolvable placeholders
97+
* should be ignored ({@code true}) or cause an exception ({@code false})
9898
*/
99-
PlaceholderParser(String prefix, String suffix, boolean ignoreUnresolvablePlaceholders,
100-
@Nullable String separator, @Nullable Character escape) {
99+
PlaceholderParser(String prefix, String suffix, @Nullable String separator,
100+
@Nullable Character escape, boolean ignoreUnresolvablePlaceholders) {
101101
this.prefix = prefix;
102102
this.suffix = suffix;
103103
String simplePrefixForSuffix = wellKnownSimplePrefixes.get(this.suffix);

spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class PropertyPlaceholderHelper {
4646
* @param placeholderSuffix the suffix that denotes the end of a placeholder
4747
*/
4848
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix) {
49-
this(placeholderPrefix, placeholderSuffix, null, true, null);
49+
this(placeholderPrefix, placeholderSuffix, null, null, true);
5050
}
5151

5252
/**
@@ -64,7 +64,7 @@ public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuf
6464
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
6565
@Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders) {
6666

67-
this(placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders, null);
67+
this(placeholderPrefix, placeholderSuffix, valueSeparator, null, ignoreUnresolvablePlaceholders);
6868
}
6969

7070
/**
@@ -73,20 +73,20 @@ public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuf
7373
* @param placeholderSuffix the suffix that denotes the end of a placeholder
7474
* @param valueSeparator the separating character between the placeholder variable
7575
* and the associated default value, if any
76-
* @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should
77-
* be ignored ({@code true}) or cause an exception ({@code false})
7876
* @param escapeCharacter the escape character to use to ignore placeholder prefix
7977
* or value separator, if any
78+
* @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should
79+
* be ignored ({@code true}) or cause an exception ({@code false})
8080
* @since 6.2
8181
*/
8282
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
83-
@Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders,
84-
@Nullable Character escapeCharacter) {
83+
@Nullable String valueSeparator, @Nullable Character escapeCharacter,
84+
boolean ignoreUnresolvablePlaceholders) {
8585

8686
Assert.notNull(placeholderPrefix, "'placeholderPrefix' must not be null");
8787
Assert.notNull(placeholderSuffix, "'placeholderSuffix' must not be null");
8888
this.parser = new PlaceholderParser(placeholderPrefix, placeholderSuffix,
89-
ignoreUnresolvablePlaceholders, valueSeparator, escapeCharacter);
89+
valueSeparator, escapeCharacter, ignoreUnresolvablePlaceholders);
9090
}
9191

9292

spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public abstract class SystemPropertyUtils {
5050

5151
private static final PropertyPlaceholderHelper strictHelper =
5252
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
53-
false, ESCAPE_CHARACTER);
53+
ESCAPE_CHARACTER, false);
5454

5555
private static final PropertyPlaceholderHelper nonStrictHelper =
5656
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
57-
true, ESCAPE_CHARACTER);
57+
ESCAPE_CHARACTER, true);
5858

5959

6060
/**

spring-core/src/test/java/org/springframework/util/PlaceholderParserTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PlaceholderParserTests {
4747
@Nested // Tests with only the basic placeholder feature enabled
4848
class OnlyPlaceholderTests {
4949

50-
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, null, null);
50+
private final PlaceholderParser parser = new PlaceholderParser("${", "}", null, null, true);
5151

5252
@ParameterizedTest(name = "{0} -> {1}")
5353
@MethodSource("placeholders")
@@ -169,7 +169,7 @@ void textWithInvalidPlaceholderIsMerged() {
169169
@Nested // Tests with the use of a separator
170170
class DefaultValueTests {
171171

172-
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", null);
172+
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, true);
173173

174174
@ParameterizedTest(name = "{0} -> {1}")
175175
@MethodSource("placeholders")
@@ -247,7 +247,7 @@ void parseWithFallbackUsingPlaceholder() {
247247
@Nested // Tests with the use of the escape character
248248
class EscapedTests {
249249

250-
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", '\\');
250+
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", '\\', true);
251251

252252
@ParameterizedTest(name = "{0} -> {1}")
253253
@MethodSource("escapedPlaceholders")
@@ -301,7 +301,7 @@ static Stream<Arguments> escapedSeparators() {
301301
@Nested
302302
class ExceptionTests {
303303

304-
private final PlaceholderParser parser = new PlaceholderParser("${", "}", false, ":", null);
304+
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, false);
305305

306306
@Test
307307
void textWithCircularReference() {

spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ void unresolvedPlaceholderAsError() {
115115
Properties props = new Properties();
116116
props.setProperty("foo", "bar");
117117

118-
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, false, null);
118+
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, null, false);
119119
assertThatExceptionOfType(PlaceholderResolutionException.class).isThrownBy(() ->
120120
helper.replacePlaceholders(text, props));
121121
}
122122

123123
@Nested
124124
class DefaultValueTests {
125125

126-
private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", true, null);
126+
private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", null, true);
127127

128128
@ParameterizedTest(name = "{0} -> {1}")
129129
@MethodSource("defaultValues")

spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
6868

6969
private String defaultUserDestinationPrefix = "/queue";
7070

71-
private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, false, null);
71+
private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, null, false);
7272

7373
@Nullable
7474
private MessageHeaderInitializer headerInitializer;

spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private static class StaticStringValueResolver implements StringValueResolver {
586586
private final PlaceholderResolver resolver;
587587

588588
public StaticStringValueResolver(Map<String, String> values) {
589-
this.helper = new PropertyPlaceholderHelper("${", "}", ":", false, null);
589+
this.helper = new PropertyPlaceholderHelper("${", "}", ":", null, false);
590590
this.resolver = values::get;
591591
}
592592

spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public abstract class ServletContextPropertyUtils {
4040
private static final PropertyPlaceholderHelper strictHelper =
4141
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
4242
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
43-
false, SystemPropertyUtils.ESCAPE_CHARACTER);
43+
SystemPropertyUtils.ESCAPE_CHARACTER, false);
4444

4545
private static final PropertyPlaceholderHelper nonStrictHelper =
4646
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
4747
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
48-
true, SystemPropertyUtils.ESCAPE_CHARACTER);
48+
SystemPropertyUtils.ESCAPE_CHARACTER, true);
4949

5050

5151
/**

0 commit comments

Comments
 (0)