Skip to content

Spring batch allows job without parameters to restart even if the job already completed successfully #4755

Open
@fmbenhassine

Description

@fmbenhassine

Discussed in #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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions