From 64f63471994f9e07795782beff4495f3beb9f628 Mon Sep 17 00:00:00 2001 From: robokaso Date: Mon, 6 Oct 2008 08:08:55 +0000 Subject: [PATCH] RESOLVED - BATCH-833: TransactionAttributes swallows Exceptions removed the redundant exception-swallowing catch block --- .../batch/core/step/tasklet/TaskletStep.java | 34 ++++++------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index 354cb67ac..40919c23a 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -52,7 +52,8 @@ import org.springframework.transaction.interceptor.TransactionAttribute; * possibly repeated, and each call surrounded by a transaction. The structure * is therefore that of a loop with transaction boundary inside the loop. The * loop is controlled by the step operations ( - * {@link #setStepOperations(RepeatOperations)}).

+ * {@link #setStepOperations(RepeatOperations)}).
+ *
* * Clients can use interceptors in the step operations to intercept or listen to * the iteration on a step-wide basis, for instance to get a callback when the @@ -231,7 +232,7 @@ public class TaskletStep extends AbstractStep { StepContribution contribution = stepExecution.createStepContribution(); stepExecution.getExecutionContext().clearDirtyFlag(); - + // Before starting a new transaction, check for // interruption. interruptionPolicy.checkInterrupted(stepExecution); @@ -252,22 +253,6 @@ public class TaskletStep extends AbstractStep { try { exitStatus = tasklet.execute(contribution, attributes); } - catch (Error e) { - if (transactionAttribute.rollbackOn(e)) { - throw e; - } - else { - logger.error("Ecountered error that should not cause rollback: ", e); - } - } - catch (Exception e) { - if (transactionAttribute.rollbackOn(e)) { - throw e; - } - else { - logger.error("Ecountered error that should not cause rollback: ", e); - } - } finally { // Still some stuff to do with the data in this chunk, // pass it back @@ -296,12 +281,15 @@ public class TaskletStep extends AbstractStep { Thread.currentThread().interrupt(); } - //Check to make sure the ExecutionContext hasn't be modified outside a chunk boundary. Doing so will cause potential - //rollback issues. - if(stepExecution.getExecutionContext().isDirty()){ - throw new IllegalStateException("The ExecutionContext cannot be modified outside of the ItemStream#Update method"); + // Check to make sure the ExecutionContext hasn't be + // modified outside a chunk boundary. Doing so will cause + // potential + // rollback issues. + if (stepExecution.getExecutionContext().isDirty()) { + throw new IllegalStateException( + "The ExecutionContext cannot be modified outside of the ItemStream#Update method"); } - + stream.update(stepExecution.getExecutionContext()); try {