Set step end time before calling StepExecutionListener#afterStep
Resolves #3846
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
ff0fb97272
commit
df5e8e1686
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2023 the original author or authors.
|
||||
* Copyright 2006-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,6 +63,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Michael Minella
|
||||
* @author Chris Schaefer
|
||||
* @author Mahmoud Ben Hassine
|
||||
* @author Jinwoo Bae
|
||||
*/
|
||||
public abstract class AbstractStep implements Step, InitializingBean, BeanNameAware {
|
||||
|
||||
@@ -261,7 +262,13 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
stepExecution.setEndTime(LocalDateTime.now());
|
||||
Duration stepExecutionDuration = BatchMetrics.calculateDuration(stepExecution.getStartTime(),
|
||||
stepExecution.getEndTime());
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Step: [" + stepExecution.getStepName() + "] executed in "
|
||||
+ BatchMetrics.formatDuration(stepExecutionDuration));
|
||||
}
|
||||
try {
|
||||
// Update the step execution to the latest known value so the
|
||||
// listeners can act on it
|
||||
@@ -287,14 +294,8 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
|
||||
}
|
||||
stopObservation(stepExecution, observation);
|
||||
stepExecution.setEndTime(LocalDateTime.now());
|
||||
stepExecution.setExitStatus(exitStatus);
|
||||
Duration stepExecutionDuration = BatchMetrics.calculateDuration(stepExecution.getStartTime(),
|
||||
stepExecution.getEndTime());
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Step: [" + stepExecution.getStepName() + "] executed in "
|
||||
+ BatchMetrics.formatDuration(stepExecutionDuration));
|
||||
}
|
||||
|
||||
try {
|
||||
getJobRepository().update(stepExecution);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user