From bad8491fa4b9956abba29d40f83959e979d26913 Mon Sep 17 00:00:00 2001 From: trisberg Date: Tue, 28 Oct 2008 15:21:26 +0000 Subject: [PATCH] BATCH-859: changed the logic to throw a RetryException when a non-rollback exception is encountered during write --- .../step/item/FaultTolerantChunkOrientedTasklet.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTasklet.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTasklet.java index 20f228634..9a0c21b06 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTasklet.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/item/FaultTolerantChunkOrientedTasklet.java @@ -250,7 +250,7 @@ public class FaultTolerantChunkOrientedTasklet extends AbstractItemOriente if (processSkipPolicy.shouldSkip(e, contribution.getStepSkipCount())) { contribution.incrementProcessSkipCount(); skippedInputs.put(item, e); - + logger.debug("Skipping after failed process", e); return null; } else { @@ -303,6 +303,11 @@ public class FaultTolerantChunkOrientedTasklet extends AbstractItemOriente checkSkipPolicy(item, e, contribution); return null; } + Exception le = (Exception) context.getLastThrowable(); + if (!rollbackClassifier.classify(le)) { + throw new RetryException( + "Invalid retry state caused by exception that does not classify for rollback during write: ", le); + } for (S item : chunk) { try { doWrite(Collections.singletonList(item)); @@ -314,7 +319,8 @@ public class FaultTolerantChunkOrientedTasklet extends AbstractItemOriente throw e; } else { - logger.error("Exception encountered that does not classify for rollback: ", e); + throw new RetryException( + "Invalid retry state caused by exception that does not classify for rollback during recovery: ", e); } } } @@ -327,6 +333,7 @@ public class FaultTolerantChunkOrientedTasklet extends AbstractItemOriente if (writeSkipPolicy.shouldSkip(e, contribution.getStepSkipCount())) { contribution.incrementWriteSkipCount(); skipped.put(item, e); + logger.debug("Skipping after failed write", e); } else { throw new RetryException("Non-skippable exception in recoverer", e);