From d1ab2086a6db9341e7b0766598ffb9bcda657068 Mon Sep 17 00:00:00 2001 From: dsyer Date: Sat, 2 Feb 2008 14:31:30 +0000 Subject: [PATCH] IN PROGRESS - issue BATCH-7: Remove transaction synchronization and state management from input/output sources (formerly buffering) http://jira.springframework.org/browse/BATCH-7 Remove unnecessary usage of GenericStreamContext --- .../batch/execution/step/simple/SimpleStepExecutor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java index e2982223a..dcda44d86 100644 --- a/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java +++ b/spring-batch-execution/src/main/java/org/springframework/batch/execution/step/simple/SimpleStepExecutor.java @@ -35,7 +35,6 @@ import org.springframework.batch.io.Skippable; import org.springframework.batch.io.exception.BatchCriticalException; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.StreamContext; -import org.springframework.batch.item.stream.GenericStreamContext; import org.springframework.batch.item.stream.SimpleStreamManager; import org.springframework.batch.item.stream.StreamManager; import org.springframework.batch.repeat.ExitStatus; @@ -225,10 +224,14 @@ public class SimpleStepExecutor { // aggregate these contributions if they // come in asynchronously. StreamContext statistics = stepContext.getStreamContext(); - contribution.setStreamContext(new GenericStreamContext(statistics.getProperties())); + contribution.setStreamContext(statistics); contribution.incrementCommitCount(); + // If the step operations are asynchronous then we need + // to synchronize changes to the step execution (at a + // minimum). synchronized (stepExecution) { + // Apply the contribution to the step // only if chunk was successful stepExecution.apply(contribution); @@ -238,6 +241,7 @@ public class SimpleStepExecutor { jobRepository.update(stepInstance); } jobRepository.saveOrUpdate(stepExecution); + } streamManager.commit(transaction);