fix race condition
This commit is contained in:
parent
1a1243db34
commit
3e7eec4e9e
|
@ -62,10 +62,11 @@ public class BatchJobHelper {
|
|||
public List<JobExecution> awaitAllBulkJobCompletions(boolean theFailIfNotJobsFound, String... theJobNames) {
|
||||
assert theJobNames.length > 0;
|
||||
|
||||
List<JobInstance> matchingJobInstances = new ArrayList<>();
|
||||
for (String nextName : theJobNames) {
|
||||
matchingJobInstances.addAll(myJobExplorer.findJobInstancesByJobName(nextName, 0, 100));
|
||||
if (theFailIfNotJobsFound) {
|
||||
await().until(() -> !getJobInstances(theJobNames).isEmpty());
|
||||
}
|
||||
List<JobInstance> matchingJobInstances = getJobInstances(theJobNames);
|
||||
|
||||
if (theFailIfNotJobsFound) {
|
||||
if (matchingJobInstances.isEmpty()) {
|
||||
List<String> wantNames = Arrays.asList(theJobNames);
|
||||
|
@ -81,6 +82,14 @@ public class BatchJobHelper {
|
|||
return matchingExecutions;
|
||||
}
|
||||
|
||||
private List<JobInstance> getJobInstances(String[] theJobNames) {
|
||||
List<JobInstance> matchingJobInstances = new ArrayList<>();
|
||||
for (String nextName : theJobNames) {
|
||||
matchingJobInstances.addAll(myJobExplorer.findJobInstancesByJobName(nextName, 0, 100));
|
||||
}
|
||||
return matchingJobInstances;
|
||||
}
|
||||
|
||||
public JobExecution awaitJobExecution(Long theJobExecutionId) {
|
||||
JobExecution jobExecution = myJobExplorer.getJobExecution(theJobExecutionId);
|
||||
awaitJobCompletion(jobExecution);
|
||||
|
|
Loading…
Reference in New Issue