Consistently declare ignoreUnresolvablePlaceholders as last argument

This commit is contained in:
Sam Brannen 2024-02-16 14:07:46 +01:00
parent 7c07c43201
commit ea4e7df9ca
10 changed files with 25 additions and 25 deletions

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
/**

View File

@ -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() {

View File

@ -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")

View File

@ -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;

View File

@ -586,7 +586,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
private final PlaceholderResolver resolver;
public StaticStringValueResolver(Map<String, String> values) {
this.helper = new PropertyPlaceholderHelper("${", "}", ":", false, null);
this.helper = new PropertyPlaceholderHelper("${", "}", ":", null, false);
this.resolver = values::get;
}

View File

@ -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);
/**