Fix circular placeholder prevention

Issue: SPR-5369
This commit is contained in:
Juergen Hoeller
2012-10-31 02:18:43 +01:00
parent e491d990de
commit 4169898842

View File

@@ -135,13 +135,13 @@ public class PropertyPlaceholderHelper {
int endIndex = findPlaceholderEndIndex(buf, startIndex);
if (endIndex != -1) {
String placeholder = buf.substring(startIndex + this.placeholderPrefix.length(), endIndex);
if (!visitedPlaceholders.add(placeholder)) {
String originalPlaceholder = placeholder;
if (!visitedPlaceholders.add(originalPlaceholder)) {
throw new IllegalArgumentException(
"Circular placeholder reference '" + placeholder + "' in property definitions");
"Circular placeholder reference '" + originalPlaceholder + "' in property definitions");
}
// Recursive invocation, parsing placeholders contained in the placeholder key.
placeholder = parseStringValue(placeholder, placeholderResolver, visitedPlaceholders);
// Now obtain the value for the fully resolved key...
String propVal = placeholderResolver.resolvePlaceholder(placeholder);
if (propVal == null && this.valueSeparator != null) {
@@ -171,10 +171,9 @@ public class PropertyPlaceholderHelper {
}
else {
throw new IllegalArgumentException("Could not resolve placeholder '" +
placeholder + "'" + " in string value [" + strVal + "]");
placeholder + "'" + " in string value \"" + strVal + "\"");
}
visitedPlaceholders.remove(placeholder);
visitedPlaceholders.remove(originalPlaceholder);
}
else {
startIndex = -1;