From bda4cd1917862308d8f99c301e1219462f034292 Mon Sep 17 00:00:00 2001 From: Glenn Renfro Date: Wed, 14 Sep 2022 11:00:12 -0400 Subject: [PATCH] StartTime is now honored for TaskExecution regardless if they were created before or during task execution. resolves #861 Readded check for duplicate launch request --- .../task/listener/TaskLifecycleListener.java | 15 ++++++------- .../task/executionid/TaskStartTests.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java index 0f982124..271b8a81 100644 --- a/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java +++ b/spring-cloud-task-core/src/main/java/org/springframework/cloud/task/listener/TaskLifecycleListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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. @@ -276,14 +276,13 @@ public class TaskLifecycleListener implements ApplicationListener taskExecutions = this.taskExplorer.findAll(PageRequest.of(0, 10)); + assertThat(taskExecutions.getTotalElements()).as("Only one row is expected").isEqualTo(1); + assertThat(taskExecutions.iterator().next().getExitCode().intValue()).as("return code should be 0") + .isEqualTo(0); + assertThat(this.taskExplorer.getTaskExecution(1).getStartTime().getTime()).isEqualTo(startDate.getTime()); + + } + @Test public void testWithNoTaskExecution() throws Exception { assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(() -> {