Skip to content

Commit 4169898

Browse files
committed
Fix circular placeholder prevention
Issue: SPR-5369
1 parent e491d99 commit 4169898

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ protected String parseStringValue(
135135
int endIndex = findPlaceholderEndIndex(buf, startIndex);
136136
if (endIndex != -1) {
137137
String placeholder = buf.substring(startIndex + this.placeholderPrefix.length(), endIndex);
138-
if (!visitedPlaceholders.add(placeholder)) {
138+
String originalPlaceholder = placeholder;
139+
if (!visitedPlaceholders.add(originalPlaceholder)) {
139140
throw new IllegalArgumentException(
140-
"Circular placeholder reference '" + placeholder + "' in property definitions");
141+
"Circular placeholder reference '" + originalPlaceholder + "' in property definitions");
141142
}
142143
// Recursive invocation, parsing placeholders contained in the placeholder key.
143144
placeholder = parseStringValue(placeholder, placeholderResolver, visitedPlaceholders);
144-
145145
// Now obtain the value for the fully resolved key...
146146
String propVal = placeholderResolver.resolvePlaceholder(placeholder);
147147
if (propVal == null && this.valueSeparator != null) {
@@ -171,10 +171,9 @@ else if (this.ignoreUnresolvablePlaceholders) {
171171
}
172172
else {
173173
throw new IllegalArgumentException("Could not resolve placeholder '" +
174-
placeholder + "'" + " in string value [" + strVal + "]");
174+
placeholder + "'" + " in string value \"" + strVal + "\"");
175175
}
176-
177-
visitedPlaceholders.remove(placeholder);
176+
visitedPlaceholders.remove(originalPlaceholder);
178177
}
179178
else {
180179
startIndex = -1;

0 commit comments

Comments
 (0)