diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MongoStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MongoStepExecutionDao.java index 44215babd..9b889c1d8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MongoStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/MongoStepExecutionDao.java @@ -111,6 +111,7 @@ public class MongoStepExecutionDao implements StepExecutionDao { // first one Optional lastStepExecution = stepExecutions .stream() + .filter(stepExecution -> stepExecution.getName().equals(stepName)) .min(Comparator .comparing(org.springframework.batch.core.repository.persistence.StepExecution::getCreateTime) .thenComparing(org.springframework.batch.core.repository.persistence.StepExecution::getId));