diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java index 592434f39..04e6ac19d 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/scope/util/PlaceholderTargetSource.java @@ -330,7 +330,7 @@ public class PlaceholderTargetSource extends SimpleBeanTargetSource implements I // Otherwise it might contain embedded keys so we try to // replace those String visitedString = resolveStringValue(stringValue); - typedStringValue.setValue(visitedString); + value = new TypedStringValue(visitedString); } } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java index 82b6c17cb..dc9f669b5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests.java @@ -53,6 +53,10 @@ public class MultipleContextPlaceholderTargetSourceTests { @Qualifier("simple") private TestBean simple; + @Autowired + @Qualifier("nested") + private TestBean nested; + @Autowired @Qualifier("list") private TestBean list; @@ -88,6 +92,17 @@ public class MultipleContextPlaceholderTargetSourceTests { } + @Test + public void testMultipleNestedValueFromProperties() throws Exception { + + for (int i = 0; i < 4; i++) { + final String value = "bar" + i; + attributes = Collections.singletonMap("foo", value); + assertEquals("foo-bar" + i, nested.getName()); + } + + } + @Test public void testMultipleValueInList() throws Exception { diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml index 30e331586..672f3c01d 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/scope/util/MultipleContextPlaceholderTargetSourceTests-context.xml @@ -16,6 +16,16 @@ + + + + + + + + + + + + +