From 9256148cf2193b7497148ddfe42ce89aa459694f Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 12 Jul 2017 16:46:56 -0400 Subject: [PATCH] BATCH-2630 - update not to rely on step execution order from DAO --- .../batch/core/repository/support/SimpleJobRepository.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java index 0d9e9e646..717a77294 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java @@ -236,6 +236,11 @@ public class SimpleJobRepository implements JobRepository { if (latest.getStartTime().getTime() < stepExecution.getStartTime().getTime()) { latest = stepExecution; } + // Use step execution ID as the tie breaker if start time is identical + if (latest.getStartTime().getTime() == stepExecution.getStartTime().getTime() && + latest.getId() < stepExecution.getId()) { + latest = stepExecution; + } } if (latest != null) {