|
1 | 1 | /*
|
2 |
| - * Copyright 2006-2019 the original author or authors. |
| 2 | + * Copyright 2006-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
21 | 21 | import org.springframework.batch.core.BatchStatus;
|
22 | 22 | import org.springframework.batch.core.JobExecution;
|
23 | 23 | import org.springframework.batch.core.JobInstance;
|
| 24 | +import org.springframework.batch.core.JobParameter; |
24 | 25 | import org.springframework.batch.core.JobParameters;
|
25 | 26 | import org.springframework.batch.core.StepExecution;
|
26 | 27 | import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
|
51 | 52 | * @author Robert Kasanicky
|
52 | 53 | * @author David Turanski
|
53 | 54 | * @author Mahmoud Ben Hassine
|
| 55 | + * @author Baris Cubukcuoglu |
54 | 56 | *
|
55 | 57 | * @see JobRepository
|
56 | 58 | * @see JobInstanceDao
|
@@ -131,7 +133,9 @@ public JobExecution createJobExecution(String jobName, JobParameters jobParamete
|
131 | 133 | + "The last execution ended with a failure that could not be rolled back, "
|
132 | 134 | + "so it may be dangerous to proceed. Manual intervention is probably necessary.");
|
133 | 135 | }
|
134 |
| - if (execution.getJobParameters().getParameters().size() > 0 && (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) { |
| 136 | + Collection<JobParameter> allJobParameters = execution.getJobParameters().getParameters().values(); |
| 137 | + long identifyingJobParametersCount = allJobParameters.stream().filter(JobParameter::isIdentifying).count(); |
| 138 | + if (identifyingJobParametersCount > 0 && (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) { |
135 | 139 | throw new JobInstanceAlreadyCompleteException(
|
136 | 140 | "A job instance already exists and is complete for parameters=" + jobParameters
|
137 | 141 | + ". If you want to run this job again, change the parameters.");
|
|
0 commit comments