From 0506d3793e50a606cd9739ce896de5d80b474e8e 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 --- .../core/repository/support/SimpleJobRepository.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 8398b050e..ac5994615 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 @@ -229,9 +229,12 @@ public class SimpleJobRepository implements JobRepository { if (latest == null) { latest = stepExecution; } - // Ordered by step execution ID so less than or equal makes last step execution ID - // the tie breaker if start time is identical - if (latest.getStartTime().getTime() <= stepExecution.getStartTime().getTime()) { + 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; } }