MyClass.java

protected LinkedBlockingDeque<JobSet> currentWork = new LinkedBlockingDeque<JobSet>();

public LinkedBlockingDeque<JobSet> getCurrentWork() {
    return currentWork;
}

用法
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;
}

它期待JobSet但得到Object。对我来说,很明显它正在返回正确的对象,那么我错过了什么?
Error: java: incompatible types
  required: com.production.model.JobSet
  found:    java.lang.Object

最佳答案

每条评论:使用Iterator应该可以解决问题。我的猜测是在迭代列表并同时删除一个项目时存在干扰,导致循环读取已删除的值。

关于java - 为什么我的退货值(value)无法正确识别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17883955/

10-11 04:00