RESOLVED - issue BATCH-603: JobExecution fields could be modified in another Thread and are not volatile
Added final and volatile as appropriate in domain entities.
This commit is contained in:
@@ -31,21 +31,17 @@ import org.springframework.batch.repeat.ExitStatus;
|
||||
*/
|
||||
public class JobExecution extends Entity {
|
||||
|
||||
private JobInstance jobInstance;
|
||||
private final JobInstance jobInstance;
|
||||
|
||||
private transient Collection stepExecutions = new HashSet();
|
||||
|
||||
private BatchStatus status = BatchStatus.STARTING;
|
||||
private volatile BatchStatus status = BatchStatus.STARTING;
|
||||
|
||||
private Date startTime = null;
|
||||
private volatile Date startTime = null;
|
||||
|
||||
private Date endTime = null;
|
||||
private volatile Date endTime = null;
|
||||
|
||||
private ExitStatus exitStatus = ExitStatus.UNKNOWN;
|
||||
|
||||
// Package private constructor for testing
|
||||
JobExecution() {
|
||||
}
|
||||
private volatile ExitStatus exitStatus = ExitStatus.UNKNOWN;
|
||||
|
||||
/**
|
||||
* Because a JobExecution isn't valid unless the job is set, this
|
||||
@@ -125,10 +121,6 @@ public class JobExecution extends Entity {
|
||||
return jobInstance;
|
||||
}
|
||||
|
||||
public void setJobInstance(JobInstance jobInstance) {
|
||||
this.jobInstance = jobInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessor for the step executions.
|
||||
*
|
||||
|
||||
@@ -39,9 +39,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JobInstance extends Entity {
|
||||
|
||||
private JobParameters jobParameters;
|
||||
private final JobParameters jobParameters;
|
||||
|
||||
private String jobName;
|
||||
private final String jobName;
|
||||
|
||||
public JobInstance(Long id, JobParameters jobParameters, String jobName) {
|
||||
super(id);
|
||||
|
||||
@@ -24,17 +24,17 @@ package org.springframework.batch.core;
|
||||
*/
|
||||
public class StepContribution {
|
||||
|
||||
private int itemCount = 0;
|
||||
private volatile int itemCount = 0;
|
||||
|
||||
private int parentSkipCount;
|
||||
private final int parentSkipCount;
|
||||
|
||||
private int commitCount;
|
||||
private volatile int commitCount;
|
||||
|
||||
private int readSkipCount;
|
||||
private volatile int readSkipCount;
|
||||
|
||||
private int writeSkipCount;
|
||||
private volatile int writeSkipCount;
|
||||
|
||||
private int uncommitedReadSkipCount;
|
||||
private volatile int uncommitedReadSkipCount;
|
||||
|
||||
/**
|
||||
* @param execution
|
||||
|
||||
@@ -35,38 +35,31 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class StepExecution extends Entity {
|
||||
|
||||
private JobExecution jobExecution;
|
||||
private final JobExecution jobExecution;
|
||||
|
||||
private String stepName;
|
||||
private final String stepName;
|
||||
|
||||
private BatchStatus status = BatchStatus.STARTING;
|
||||
private volatile BatchStatus status = BatchStatus.STARTING;
|
||||
|
||||
private int itemCount = 0;
|
||||
private volatile int itemCount = 0;
|
||||
|
||||
private int commitCount = 0;
|
||||
private volatile int commitCount = 0;
|
||||
|
||||
private int rollbackCount = 0;
|
||||
private volatile int rollbackCount = 0;
|
||||
|
||||
private int readSkipCount = 0;
|
||||
private volatile int readSkipCount = 0;
|
||||
|
||||
private int writeSkipCount = 0;
|
||||
private volatile int writeSkipCount = 0;
|
||||
|
||||
private Date startTime = new Date(System.currentTimeMillis());
|
||||
private volatile Date startTime = new Date(System.currentTimeMillis());
|
||||
|
||||
private Date endTime = null;
|
||||
private volatile Date endTime = null;
|
||||
|
||||
private ExecutionContext executionContext = new ExecutionContext();
|
||||
private volatile ExecutionContext executionContext = new ExecutionContext();
|
||||
|
||||
private ExitStatus exitStatus = ExitStatus.UNKNOWN;
|
||||
private volatile ExitStatus exitStatus = ExitStatus.UNKNOWN;
|
||||
|
||||
private boolean terminateOnly;
|
||||
|
||||
/**
|
||||
* Package private constructor for Hibernate
|
||||
*/
|
||||
StepExecution() {
|
||||
super();
|
||||
}
|
||||
private volatile boolean terminateOnly;
|
||||
|
||||
/**
|
||||
* Constructor with mandatory properties.
|
||||
|
||||
Reference in New Issue
Block a user