Consistently declare ignoreUnresolvablePlaceholders as last argument
This commit is contained in:
parent
7c07c43201
commit
ea4e7df9ca
|
@ -235,7 +235,7 @@ public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
|
||||||
public PlaceholderResolvingStringValueResolver(Properties props) {
|
public PlaceholderResolvingStringValueResolver(Properties props) {
|
||||||
this.helper = new PropertyPlaceholderHelper(
|
this.helper = new PropertyPlaceholderHelper(
|
||||||
placeholderPrefix, placeholderSuffix, valueSeparator,
|
placeholderPrefix, placeholderSuffix, valueSeparator,
|
||||||
ignoreUnresolvablePlaceholders, escapeCharacter);
|
escapeCharacter, ignoreUnresolvablePlaceholders);
|
||||||
this.resolver = new PropertyPlaceholderConfigurerResolver(props);
|
this.resolver = new PropertyPlaceholderConfigurerResolver(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ public abstract class AbstractPropertyResolver implements ConfigurablePropertyRe
|
||||||
|
|
||||||
private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) {
|
private PropertyPlaceholderHelper createPlaceholderHelper(boolean ignoreUnresolvablePlaceholders) {
|
||||||
return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix,
|
return new PropertyPlaceholderHelper(this.placeholderPrefix, this.placeholderSuffix,
|
||||||
this.valueSeparator, ignoreUnresolvablePlaceholders, this.escapeCharacter);
|
this.valueSeparator, this.escapeCharacter, ignoreUnresolvablePlaceholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) {
|
private String doResolvePlaceholders(String text, PropertyPlaceholderHelper helper) {
|
||||||
|
|
|
@ -89,15 +89,15 @@ final class PlaceholderParser {
|
||||||
* Create an instance using the specified input for the parser.
|
* Create an instance using the specified input for the parser.
|
||||||
* @param prefix the prefix that denotes the start of a placeholder
|
* @param prefix the prefix that denotes the start of a placeholder
|
||||||
* @param suffix the suffix that denotes the end 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
|
* @param separator the separating character between the placeholder
|
||||||
* variable and the associated default value, if any
|
* variable and the associated default value, if any
|
||||||
* @param escape the character to use at the beginning of a placeholder
|
* @param escape the character to use at the beginning of a placeholder
|
||||||
* prefix or separator to escape it and render it as is
|
* 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,
|
PlaceholderParser(String prefix, String suffix, @Nullable String separator,
|
||||||
@Nullable String separator, @Nullable Character escape) {
|
@Nullable Character escape, boolean ignoreUnresolvablePlaceholders) {
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.suffix = suffix;
|
this.suffix = suffix;
|
||||||
String simplePrefixForSuffix = wellKnownSimplePrefixes.get(this.suffix);
|
String simplePrefixForSuffix = wellKnownSimplePrefixes.get(this.suffix);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class PropertyPlaceholderHelper {
|
||||||
* @param placeholderSuffix the suffix that denotes the end of a placeholder
|
* @param placeholderSuffix the suffix that denotes the end of a placeholder
|
||||||
*/
|
*/
|
||||||
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix) {
|
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,
|
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
|
||||||
@Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders) {
|
@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 placeholderSuffix the suffix that denotes the end of a placeholder
|
||||||
* @param valueSeparator the separating character between the placeholder variable
|
* @param valueSeparator the separating character between the placeholder variable
|
||||||
* and the associated default value, if any
|
* 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
|
* @param escapeCharacter the escape character to use to ignore placeholder prefix
|
||||||
* or value separator, if any
|
* 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
|
* @since 6.2
|
||||||
*/
|
*/
|
||||||
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
|
public PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
|
||||||
@Nullable String valueSeparator, boolean ignoreUnresolvablePlaceholders,
|
@Nullable String valueSeparator, @Nullable Character escapeCharacter,
|
||||||
@Nullable Character escapeCharacter) {
|
boolean ignoreUnresolvablePlaceholders) {
|
||||||
|
|
||||||
Assert.notNull(placeholderPrefix, "'placeholderPrefix' must not be null");
|
Assert.notNull(placeholderPrefix, "'placeholderPrefix' must not be null");
|
||||||
Assert.notNull(placeholderSuffix, "'placeholderSuffix' must not be null");
|
Assert.notNull(placeholderSuffix, "'placeholderSuffix' must not be null");
|
||||||
this.parser = new PlaceholderParser(placeholderPrefix, placeholderSuffix,
|
this.parser = new PlaceholderParser(placeholderPrefix, placeholderSuffix,
|
||||||
ignoreUnresolvablePlaceholders, valueSeparator, escapeCharacter);
|
valueSeparator, escapeCharacter, ignoreUnresolvablePlaceholders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,11 @@ public abstract class SystemPropertyUtils {
|
||||||
|
|
||||||
private static final PropertyPlaceholderHelper strictHelper =
|
private static final PropertyPlaceholderHelper strictHelper =
|
||||||
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
|
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
|
||||||
false, ESCAPE_CHARACTER);
|
ESCAPE_CHARACTER, false);
|
||||||
|
|
||||||
private static final PropertyPlaceholderHelper nonStrictHelper =
|
private static final PropertyPlaceholderHelper nonStrictHelper =
|
||||||
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
|
new PropertyPlaceholderHelper(PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, VALUE_SEPARATOR,
|
||||||
true, ESCAPE_CHARACTER);
|
ESCAPE_CHARACTER, true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,7 +47,7 @@ class PlaceholderParserTests {
|
||||||
@Nested // Tests with only the basic placeholder feature enabled
|
@Nested // Tests with only the basic placeholder feature enabled
|
||||||
class OnlyPlaceholderTests {
|
class OnlyPlaceholderTests {
|
||||||
|
|
||||||
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, null, null);
|
private final PlaceholderParser parser = new PlaceholderParser("${", "}", null, null, true);
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} -> {1}")
|
@ParameterizedTest(name = "{0} -> {1}")
|
||||||
@MethodSource("placeholders")
|
@MethodSource("placeholders")
|
||||||
|
@ -169,7 +169,7 @@ class PlaceholderParserTests {
|
||||||
@Nested // Tests with the use of a separator
|
@Nested // Tests with the use of a separator
|
||||||
class DefaultValueTests {
|
class DefaultValueTests {
|
||||||
|
|
||||||
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", null);
|
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, true);
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} -> {1}")
|
@ParameterizedTest(name = "{0} -> {1}")
|
||||||
@MethodSource("placeholders")
|
@MethodSource("placeholders")
|
||||||
|
@ -247,7 +247,7 @@ class PlaceholderParserTests {
|
||||||
@Nested // Tests with the use of the escape character
|
@Nested // Tests with the use of the escape character
|
||||||
class EscapedTests {
|
class EscapedTests {
|
||||||
|
|
||||||
private final PlaceholderParser parser = new PlaceholderParser("${", "}", true, ":", '\\');
|
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", '\\', true);
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} -> {1}")
|
@ParameterizedTest(name = "{0} -> {1}")
|
||||||
@MethodSource("escapedPlaceholders")
|
@MethodSource("escapedPlaceholders")
|
||||||
|
@ -301,7 +301,7 @@ class PlaceholderParserTests {
|
||||||
@Nested
|
@Nested
|
||||||
class ExceptionTests {
|
class ExceptionTests {
|
||||||
|
|
||||||
private final PlaceholderParser parser = new PlaceholderParser("${", "}", false, ":", null);
|
private final PlaceholderParser parser = new PlaceholderParser("${", "}", ":", null, false);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void textWithCircularReference() {
|
void textWithCircularReference() {
|
||||||
|
|
|
@ -115,7 +115,7 @@ class PropertyPlaceholderHelperTests {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.setProperty("foo", "bar");
|
props.setProperty("foo", "bar");
|
||||||
|
|
||||||
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, false, null);
|
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", null, null, false);
|
||||||
assertThatExceptionOfType(PlaceholderResolutionException.class).isThrownBy(() ->
|
assertThatExceptionOfType(PlaceholderResolutionException.class).isThrownBy(() ->
|
||||||
helper.replacePlaceholders(text, props));
|
helper.replacePlaceholders(text, props));
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ class PropertyPlaceholderHelperTests {
|
||||||
@Nested
|
@Nested
|
||||||
class DefaultValueTests {
|
class DefaultValueTests {
|
||||||
|
|
||||||
private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", true, null);
|
private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}", ":", null, true);
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} -> {1}")
|
@ParameterizedTest(name = "{0} -> {1}")
|
||||||
@MethodSource("defaultValues")
|
@MethodSource("defaultValues")
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
|
||||||
|
|
||||||
private String defaultUserDestinationPrefix = "/queue";
|
private String defaultUserDestinationPrefix = "/queue";
|
||||||
|
|
||||||
private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, false, null);
|
private final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}", null, null, false);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private MessageHeaderInitializer headerInitializer;
|
private MessageHeaderInitializer headerInitializer;
|
||||||
|
|
|
@ -586,7 +586,7 @@ public class StandaloneMockMvcBuilder extends AbstractMockMvcBuilder<StandaloneM
|
||||||
private final PlaceholderResolver resolver;
|
private final PlaceholderResolver resolver;
|
||||||
|
|
||||||
public StaticStringValueResolver(Map<String, String> values) {
|
public StaticStringValueResolver(Map<String, String> values) {
|
||||||
this.helper = new PropertyPlaceholderHelper("${", "}", ":", false, null);
|
this.helper = new PropertyPlaceholderHelper("${", "}", ":", null, false);
|
||||||
this.resolver = values::get;
|
this.resolver = values::get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,12 @@ public abstract class ServletContextPropertyUtils {
|
||||||
private static final PropertyPlaceholderHelper strictHelper =
|
private static final PropertyPlaceholderHelper strictHelper =
|
||||||
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
|
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
|
||||||
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
|
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
|
||||||
false, SystemPropertyUtils.ESCAPE_CHARACTER);
|
SystemPropertyUtils.ESCAPE_CHARACTER, false);
|
||||||
|
|
||||||
private static final PropertyPlaceholderHelper nonStrictHelper =
|
private static final PropertyPlaceholderHelper nonStrictHelper =
|
||||||
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
|
new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX,
|
||||||
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
|
SystemPropertyUtils.PLACEHOLDER_SUFFIX, SystemPropertyUtils.VALUE_SEPARATOR,
|
||||||
true, SystemPropertyUtils.ESCAPE_CHARACTER);
|
SystemPropertyUtils.ESCAPE_CHARACTER, true);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue