From 41698988423b8e70eac7dfcea70d87e41b474076 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 31 Oct 2012 02:18:43 +0100 Subject: [PATCH] Fix circular placeholder prevention Issue: SPR-5369 --- .../util/PropertyPlaceholderHelper.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java b/org.springframework.core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java index 6598f7ce8c..df814691d8 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java +++ b/org.springframework.core/src/main/java/org/springframework/util/PropertyPlaceholderHelper.java @@ -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;