From 1449eb3dc37d27b27d4a8e1329d50ec1e623ffb7 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 25 Jul 2012 13:21:29 +0100 Subject: [PATCH] BATCH-1830: only log exception at debug if it is STOPPED --- .../batch/core/step/AbstractStep.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index fb3525810..c8006c1cb 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -176,8 +176,8 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw */ public final void execute(StepExecution stepExecution) throws JobInterruptedException, UnexpectedJobExecutionException { - - logger.debug("Executing: id="+stepExecution.getId()); + + logger.debug("Executing: id=" + stepExecution.getId()); stepExecution.setStartTime(new Date()); stepExecution.setStatus(BatchStatus.STARTED); getJobRepository().update(stepExecution); @@ -209,15 +209,24 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw logger.debug("Step execution success: id=" + stepExecution.getId()); } catch (Throwable e) { - logger.error("Encountered an error executing the step", e); stepExecution.upgradeStatus(determineBatchStatus(e)); exitStatus = exitStatus.and(getDefaultExitStatusForFailure(e)); stepExecution.addFailureException(e); + if (stepExecution.getStatus() == BatchStatus.STOPPED) { + logger.info("Encountered interruption executing step: " + e.getMessage()); + if (logger.isDebugEnabled()) { + logger.debug("Full exception", e); + } + } + else { + logger.error("Encountered an error executing the step", e); + } } finally { try { - // Update the step execution to the latest known value so the listeners can act on it + // Update the step execution to the latest known value so the + // listeners can act on it exitStatus = exitStatus.and(stepExecution.getExitStatus()); stepExecution.setExitStatus(exitStatus); exitStatus = exitStatus.and(getCompositeListener().afterStep(stepExecution));