MyClass.java
protected LinkedBlockingDeque<JobSet> currentWork = new LinkedBlockingDeque<JobSet>();
public LinkedBlockingDeque<JobSet> getCurrentWork() {
return currentWork;
}
Usage
public boolean completeAllWork(CompleteWorkRequest request) {
for (JobSet jobSet : getCurrentWork()) {
//if it's approved, find the workflow process it needs to go to next and put it there
if (request.getApprovedJobSets().contains(jobSet.getUuid().toString())) {
sendToNextWorkflowProcess(jobSet);
} else {
getCurrentWork().remove(jobSet);
logger.info("Rejected JobSet: " + jobSet.getUuid());
}
}
getWorkFromQueue();
return true;
}
It's expecting a JobSet but getting an Object. It seems clear to me that it's returning the proper object, so what did I miss?
Error: java: incompatible types
required: com.production.model.JobSet
found: java.lang.Object
Per the comments: using an Iterator should solve the problem. My guess is there is interference while iterating the list and simultaneously removing an item, causing the loop to read a deleted value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With