From b1bcc8422ffd50108404f45872e9d762e368642b Mon Sep 17 00:00:00 2001 From: robokaso Date: Mon, 8 Dec 2008 15:25:32 +0000 Subject: [PATCH] RESOLVED - BATCH-950: Exception during rollback hides root cause log original exception if rollback failed --- .../batch/core/step/tasklet/TaskletStep.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 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 794c58a08..7982f192b 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 @@ -296,12 +296,24 @@ public class TaskletStep extends AbstractStep { } catch (Error e) { - processRollback(stepExecution, fatalException, transaction); - throw e; + try { + processRollback(stepExecution, fatalException, transaction); + throw e; + } + catch (Exception rollbackException) { + logger.error("Rollback failed, original error that caused the rollback is", e); + throw rollbackException; + } } catch (Exception e) { - processRollback(stepExecution, fatalException, transaction); - throw e; + try { + processRollback(stepExecution, fatalException, transaction); + throw e; + } + catch (Exception rollbackException) { + logger.error("Rollback failed, original exception that caused the rollback is", e); + throw rollbackException; + } } finally { // only release the lock if we acquired it @@ -349,6 +361,9 @@ public class TaskletStep extends AbstractStep { fatalException.setException(e); throw new FatalException("Failed while processing rollback", e); } + else { + logger.error("Failed to rollback transaction", e); + } } if (fatalException.hasException()) {