From e38764797b02a84fc554c6130d183d07864be824 Mon Sep 17 00:00:00 2001 From: dsyer Date: Sun, 4 Apr 2010 16:06:13 +0000 Subject: [PATCH] BATCH-1547: fix logic --- .../core/listener/ExecutionContextPromotionListener.java | 5 +++-- .../listener/ExecutionContextPromotionListenerTests.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java index e0bd22ec5..b5e322d91 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/listener/ExecutionContextPromotionListener.java @@ -54,11 +54,12 @@ public class ExecutionContextPromotionListener extends StepExecutionListenerSupp if (PatternMatcher.match(statusPattern, exitCode)) { for (String key : keys) { if (stepContext.containsKey(key)) { + jobContext.put(key, stepContext.get(key)); + } else { if (strict) { throw new IllegalArgumentException("The key [" + key + "] was not found in the Step's ExecutionContext."); - } - jobContext.put(key, stepContext.get(key)); + } } } break; diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java index 9b92ba69e..cf76e5b1d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/listener/ExecutionContextPromotionListenerTests.java @@ -66,6 +66,7 @@ public class ExecutionContextPromotionListenerTests { @Test public void promoteEntryStatusFound() throws Exception { ExecutionContextPromotionListener listener = new ExecutionContextPromotionListener(); + listener.setStrict(true); JobExecution jobExecution = new JobExecution(1L); StepExecution stepExecution = jobExecution.createStepExecution("step1");