Fix synchronization on isActive and isJobAdded fields in JobAcquisitionThread

Description

Reads/writes to the fields isActive and isJobAdded need to happen in a synchronized way to support concurrency. The easiest fix would be to make these two fields volatile:

private volatile boolean isActive;
private volatile boolean isJobAdded;

Extracts from current code that shows that read/write of the fields mentioned above do not happen in a synchronized way:

public class JobAcquisitionThread extends Thread {

private static Logger log = Logger.getLogger(JobAcquisitionThread.class.getName());

private final AcquireJobsCmd acquireJobsCmd;

private JobExecutor jobExecutor;
private boolean isActive = false; // !!!
private boolean isJobAdded = false; // !!!
...

while (isActive) { // !!!
int maxJobsPerAcquisition = jobExecutor.getMaxJobsPerAcquisition();
...

public void jobWasAdded() {
isJobAdded = true; // !!!

Assignee

Daniel Meyer (camunda)

Reporter

Etienne Studer

Labels

None

Fix versions

Priority

Major
Configure