spring-batch
spring-batch copied to clipboard
Spring batch allows job without parameters to restart even if the job already completed successfully
Discussed in https://github.com/spring-projects/spring-batch/discussions/4694
Originally posted by ELMORABITYounes October 28, 2024 Right now even if a job was completed successfuly, spring batch allow It to be restarted if It contains no identifying params as shown here:
if (!identifyingJobParameters.isEmpty()
&& (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) {
throw new JobInstanceAlreadyCompleteException(
"A job instance already exists and is complete for identifying parameters="
+ identifyingJobParameters + ". If you want to run this job again, "
+ "change the parameters.");
}
I am wondering why is that done like this? I mean if the job already completed why It does not throw JobInstanceAlreadyCompleteException? Shouldn't second job instance without param considered the same and hence not allow It to be restarted if already succeeded?