Skip to content

Commit 11169ba

Browse files
morenomjcfmbenhassine
authored andcommitted
Align exception message with exception handling condition
Resolves #4025
1 parent 8a6c7ac commit 11169ba

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.springframework.batch.core.BatchStatus;
2222
import org.springframework.batch.core.JobExecution;
2323
import org.springframework.batch.core.JobInstance;
24-
import org.springframework.batch.core.JobParameter;
2524
import org.springframework.batch.core.JobParameters;
2625
import org.springframework.batch.core.StepExecution;
2726
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
@@ -54,6 +53,7 @@
5453
* @author Mahmoud Ben Hassine
5554
* @author Baris Cubukcuoglu
5655
* @author Parikshit Dutta
56+
* @author Mark John Moreno
5757
* @see JobRepository
5858
* @see JobInstanceDao
5959
* @see JobExecutionDao
@@ -151,15 +151,14 @@ public JobExecution createJobExecution(String jobName, JobParameters jobParamete
151151
+ "The last execution ended with a failure that could not be rolled back, "
152152
+ "so it may be dangerous to proceed. Manual intervention is probably necessary.");
153153
}
154-
Collection<JobParameter<?>> allJobParameters = execution.getJobParameters().getParameters().values();
155-
long identifyingJobParametersCount = allJobParameters.stream()
156-
.filter(JobParameter::isIdentifying)
157-
.count();
158-
if (identifyingJobParametersCount > 0
154+
JobParameters allJobParameters = execution.getJobParameters();
155+
JobParameters identifyingJobParameters = new JobParameters(allJobParameters.getIdentifyingParameters());
156+
if (!identifyingJobParameters.isEmpty()
159157
&& (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) {
160158
throw new JobInstanceAlreadyCompleteException(
161-
"A job instance already exists and is complete for parameters=" + jobParameters
162-
+ ". If you want to run this job again, change the parameters.");
159+
"A job instance already exists and is complete for identifying parameters="
160+
+ identifyingJobParameters + ". If you want to run this job again, "
161+
+ "change the parameters.");
163162
}
164163
}
165164
executionContext = ecDao.getExecutionContext(jobExecutionDao.getLastJobExecution(jobInstance));

0 commit comments

Comments
 (0)