diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java index d5fe3bf607d..6e23f7fdeca 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java @@ -235,7 +235,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport public PlaceholderResolvingStringValueResolver(Properties props) { this.helper = new PropertyPlaceholderHelper( placeholderPrefix, placeholderSuffix, valueSeparator, - ignoreUnresolvablePlaceholders, escapeCharacter); + escapeCharacter, ignoreUnresolvablePlaceholders); this.resolver = new PropertyPlaceholderConfigurerResolver(props); } diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java index 890cfb08947..151c482b7ed 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractPropertyResolver.java @@ -248,7 +248,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) { return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix, - this.valueSeparator, ignoreUnresolvablePlaceholders, this.escapeCharacter); + this.valueSeparator, this.escapeCharacter, ignoreUnresolvablePlaceholders); } private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) { diff --git a/spring-core/src/main/java/org/springframework/util/PlaceholderParser.java b/spring-core/src/main/java/org/springframework/util/PlaceholderParser.java index ea16a255613..edc6938fc38 100644 --- a/spring-core/src/main/java/org/springframework/util/PlaceholderParser.java +++ b/spring-core/src/main/java/org/springframework/util/PlaceholderParser.java @@ -89,15 +89,15 @@ final class PlaceholderParser { * Create an instance using the specified input for the parser. * @param prefix the prefix that denotes the start of a placeholder * @param suffix the suffix that denotes the end of a placeholder - * @param ignoreUnresolvablePlaceholders whether unresolvable placeholders - * should be ignored ({@code true}) or cause an exception ({@code false}) * @param separator the separating character between the placeholder * variable and the associated default value, if any * @param escape the character to use at the beginning of a placeholder * prefix or separator to escape it and render it as is + * @param ignoreUnresolvablePlaceholders whether unresolvable placeholders + * should be ignored ({@code true}) or cause an exception ({@code false}) */ - PlaceholderParser(String prefix, String suffix, boolean ignoreUnresolvablePlaceholders, - @Nullable String separator, @Nullable Character escape) { + PlaceholderParser(String prefix, String suffix, @Nullable String separator, + @Nullable Character escape, boolean ignoreUnresolvablePlaceholders) { this.prefix = prefix; this.suffix = suffix; String simplePrefixForSuffix = wellKnownSimplePrefixes.get(this.suffix); diff --git a/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java b/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java index d6281b7576a..78cb9a2c1ff 100644 --- a/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java +++ b/spring-core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java @@ -46,7 +46,7 @@ public class PropertyPlaceholderHelper { * @param placeholderSuffix the suffix that denotes the end of a placeholder */ public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix) { - this(placeholderPrefix, placeholderSuffix, null, true, null); + this(placeholderPrefix, placeholderSuffix, null, null, true); } /** @@ -64,7 +64,7 @@ public class PropertyPlaceholderHelper { public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, @Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders) { - this(placeholderPrefix, placeholderSuffix, valueSeparator, ignoreUnresolvablePlaceholders, null); + this(placeholderPrefix, placeholderSuffix, valueSeparator, null, ignoreUnresolvablePlaceholders); } /** @@ -73,20 +73,20 @@ public class PropertyPlaceholderHelper { * @param placeholderSuffix the suffix that denotes the end of a placeholder * @param valueSeparator the separating character between the placeholder variable * and the associated default value, if any - * @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should - * be ignored ({@code true}) or cause an exception ({@code false}) * @param escapeCharacter the escape character to use to ignore placeholder prefix * or value separator, if any + * @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should + * be ignored ({@code true}) or cause an exception ({@code false}) * @since 6.2 */ public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, - @Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders, - @Nullable Character escapeCharacter) { + @Nullable String valueSeparator, @Nullable Character escapeCharacter, + boolean ignoreUnresolvablePlaceholders) { Assert.notNull(placeholderPrefix, "'placeholderPrefix' must not be null"); Assert.notNull(placeholderSuffix, "'placeholderSuffix' must not be null"); this.parser = new PlaceholderParser(placeholderPrefix, placeholderSuffix, - ignoreUnresolvablePlaceholders, valueSeparator, escapeCharacter); + valueSeparator, escapeCharacter, ignoreUnresolvablePlaceholders); } diff --git a/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java b/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java index 8fa95ebff85..44d7712f390 100644 --- a/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java @@ -50,11 +50,11 @@ public abstract class SystemPropertyUtils { private static final PropertyPlaceholderHelper strictHelper = new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR, - false, ESCAPE_CHARACTER); + ESCAPE_CHARACTER, false); private static final PropertyPlaceholderHelper nonStrictHelper = new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR, - true, ESCAPE_CHARACTER); + ESCAPE_CHARACTER, true); /** diff --git a/spring-core/src/test/java/org/springframework/util/PlaceholderParserTests.java b/spring-core/src/test/java/org/springframework/util/PlaceholderParserTests.java index 87aedf1c6e5..07f5ac43a07 100644 --- a/spring-core/src/test/java/org/springframework/util/PlaceholderParserTests.java +++ b/spring-core/src/test/java/org/springframework/util/PlaceholderParserTests.java @@ -47,7 +47,7 @@ class PlaceholderParserTests { @Nested // Tests with only the basic placeholder feature enabled class OnlyPlaceholderTests { - private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, null, null); + private final PlaceholderParser parser = new PlaceholderParser("${", "}", null, null, true); @ParameterizedTest(name = "{0} -> {1}") @MethodSource("placeholders") @@ -169,7 +169,7 @@ class PlaceholderParserTests { @Nested // Tests with the use of a separator class DefaultValueTests { - private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", null); + private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, true); @ParameterizedTest(name = "{0} -> {1}") @MethodSource("placeholders") @@ -247,7 +247,7 @@ class PlaceholderParserTests { @Nested // Tests with the use of the escape character class EscapedTests { - private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", '\\'); + private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", '\\', true); @ParameterizedTest(name = "{0} -> {1}") @MethodSource("escapedPlaceholders") @@ -301,7 +301,7 @@ class PlaceholderParserTests { @Nested class ExceptionTests { - private final PlaceholderParser parser = new PlaceholderParser("${", "}", false, ":", null); + private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, false); @Test void textWithCircularReference() { diff --git a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java index 2b973300460..3b0e1650177 100644 --- a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java +++ b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java @@ -115,7 +115,7 @@ class PropertyPlaceholderHelperTests { Properties props = new Properties(); props.setProperty("foo", "bar"); - PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, false, null); + PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, null, false); assertThatExceptionOfType(PlaceholderResolutionException.class).isThrownBy(() -> helper.replacePlaceholders(text, props)); } @@ -123,7 +123,7 @@ class PropertyPlaceholderHelperTests { @Nested class DefaultValueTests { - private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", true, null); + private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", null, true); @ParameterizedTest(name = "{0} -> {1}") @MethodSource("defaultValues") diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java index 88a65e9c22d..44bc35404c5 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandler.java @@ -68,7 +68,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH private String defaultUserDestinationPrefix = "/queue"; - private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, false, null); + private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, null, false); @Nullable private MessageHeaderInitializer headerInitializer; diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java index 40b3d74a2df..b96b89cb1d8 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/setup/StandaloneMockMvcBuilder.java @@ -586,7 +586,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder values) { - this.helper = new PropertyPlaceholderHelper("${", "}", ":", false, null); + this.helper = new PropertyPlaceholderHelper("${", "}", ":", null, false); this.resolver = values::get; } diff --git a/spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java b/spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java index 3c8f9cce2b9..cdb3dd7e34b 100644 --- a/spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/ServletContextPropertyUtils.java @@ -40,12 +40,12 @@ public abstract class ServletContextPropertyUtils { private static final PropertyPlaceholderHelper strictHelper = new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX, SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR, - false, SystemPropertyUtils.ESCAPE_CHARACTER); + SystemPropertyUtils.ESCAPE_CHARACTER, false); private static final PropertyPlaceholderHelper nonStrictHelper = new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX, SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR, - true, SystemPropertyUtils.ESCAPE_CHARACTER); + SystemPropertyUtils.ESCAPE_CHARACTER, true); /**