-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: bug
Description
Bug description
The dirty flag of ExecutionContext is never cleared because org.springframework.batch.infrastructure.item.ExecutionContext#clearDirtyFlag() is never called.
Environment
Spring Batch version 6.0.2
Java version: 17.0.1
Database: H2 2.4.240
Steps to reproduce
- Dirty a job or step execution context by calling one of the put* methods
- Call
JobRepository#updateExecutionContext - Call
ExecutionContext#isDirty()
Expected behavior
I would expect org.springframework.batch.core.repository.JobRepository#updateExecutionContext(StepExecution) and org.springframework.batch.core.repository.JobRepository#updateExecutionContext(JobExecution) to clear the dirty flag.
Minimal Complete Reproducible example
Add to org.springframework.batch.core.repository.support.AbstractJobRepositoryIntegrationTests
/*
* Save execution context clears the dirty flag.
*/
@Test
void testUpdateRestesDirtyFlag() {
JobInstance jobInstance = jobRepository.createJobInstance(job.getName(), jobParameters);
JobExecution jobExec = jobRepository.createJobExecution(jobInstance, jobParameters, new ExecutionContext());
jobExec.setStartTime(LocalDateTime.now());
ExecutionContext ctx = new ExecutionContext();
ctx.put("crashedPosition", 7);
jobExec.setExecutionContext(ctx);
assertTrue(ctx.isDirty());
jobRepository.updateExecutionContext(jobExec);
assertFalse(ctx.isDirty());
Step step = new StepSupport("step1");
StepExecution stepExec = jobRepository.createStepExecution(step.getName(), jobExec);
ctx = new ExecutionContext(ctx);
ctx.put("crashedPosition", 8);
stepExec.setExecutionContext(ctx);
assertTrue(ctx.isDirty());
jobRepository.updateExecutionContext(stepExec);
assertFalse(ctx.isDirty());
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: waiting-for-triageIssues that we did not analyse yetIssues that we did not analyse yettype: bug