Skip to content

SimpleJobRepository should ignore non-identifying JobParameters #1221

Closed
@spring-projects-issues

Description

@spring-projects-issues

Trevor Baker opened BATCH-2383 and commented

Using the CommandLineJobRunner I pass in some non-identifying parameters but when I rerun with the same parameter, SimpleJobRepository throws an exception:

2015-05-14 12:03:58,414 [ERROR] org.springframework.batch.core.launch.support.CommandLineJobRunner#start:368 | Job Terminated in error: A job instance already exists and is complete for parameters={report.date=1431586800000}.  If you want to run this job again, change the parameters.
org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={report.date=1431586800000}.  If you want to run this job again, change the parameters.
        at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:126)

This is because SimpleJobRepository only checks the number of JobParameters but doesn't check if they are identifying or not.

BatchStatus status = execution.getStatus();
if (execution.getJobParameters().getParameters().size() > 0 && (status == BatchStatus.COMPLETED || status == BatchStatus.ABANDONED)) {
	throw new JobInstanceAlreadyCompleteException(
			"A job instance already exists and is complete for parameters=" + jobParameters
			+ ".  If you want to run this job again, change the parameters.");
}

Related Jira: BATCH-1412


Affects: 3.0.3

Attachments:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions