Explicitly considering Start Time not being null for running Job Executions

This is to exclude from capturing erroneous Job Executions. An example is
whenever a TaskRejectedException is thrown after submitting to the
taskExecutor in SimpleJobLauncher#run(), the JobExecution is left without
a Start or End Time. Also related tests are fixed.

Resolves BATCH-2675
This commit is contained in:
Dimitrios Liapis
2018-10-18 22:51:04 +02:00
committed by Mahmoud Ben Hassine
parent 76f8cad29a
commit f8f8a02a4d
11 changed files with 72 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-2018 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.
@@ -18,6 +18,7 @@ package org.springframework.batch.core.test.repository;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -204,6 +205,11 @@ public class JdbcJobRepositoryTests {
try {
JobExecution execution = repository.createJobExecution(job.getName(), new JobParameters());
//simulate running execution
execution.setStartTime(new Date());
repository.update(execution);
cacheJobIds(execution);
list.add(execution);
Thread.sleep(1000);