BATCH-1208: Modified PlaceholderTargetSource to remove the path from resolveStringValue() that handles values that start with "#{" and end with "}". This was causing problems for values like "#{run.id}" or "#{integer}-#{integer}" where replacements were expected. The special path was added to handle references, where a replacement should not take place. Since a replacement is not expected, removing the path caused an exception to be thrown to indicate that no replacement had occurred. This exception was changed to a logging statement to allow this case.

This commit is contained in:
dhgarrette
2009-04-23 22:52:13 +00:00
parent 5519d0ae1f
commit 0bcc36927b
6 changed files with 37 additions and 26 deletions

View File

@@ -170,15 +170,6 @@ public class PlaceholderTargetSource extends SimpleBeanTargetSource implements I
if (!strVal.contains(PLACEHOLDER_PREFIX)) {
return strVal;
}
if (strVal.startsWith(PLACEHOLDER_PREFIX) && strVal.endsWith(PLACEHOLDER_SUFFIX)) {
// If the whole value is a placeholder it might
// be possible to replace it all in one go as a
// String (e.g. if it's a ref=#{})
StringBuilder result = new StringBuilder(strVal);
String key = extractKey(strVal);
replaceIfTypeMatches(result, 0, strVal.length() - 1, key, String.class, typeConverter);
return result.toString();
}
return replacePlaceholders(strVal, contextTypeConverter);
}
}) {
@@ -327,7 +318,7 @@ public class PlaceholderTargetSource extends SimpleBeanTargetSource implements I
replaced |= replaceIfTypeMatches(result, first, next, key, Integer.class, typeConverter);
replaced |= replaceIfTypeMatches(result, first, next, key, Date.class, typeConverter);
if (!replaced) {
throw new IllegalStateException("Cannot bind to placeholder: "+key);
logger.debug("Cannot bind to placeholder: " + key);
}
first = result.indexOf(PLACEHOLDER_PREFIX, first + 1);
next = result.indexOf(PLACEHOLDER_SUFFIX, first + 1);