Program: 80312
Project: 80312
Buggy source:
/** 
 * Wait for all workers done in current iteration.
 */
@Override public void preIteration(final MasterContext<MASTER_RESULT,WORKER_RESULT> context){
synchronized (LOCK) {
    this.currentInteration=context.getCurrentIteration();
    this.canUpdateWorkerResultMap=true;
  }
  long start=System.nanoTime();
  new RetryCoordinatorCommand(isFixedTime(),getSleepTime()){
    @Override public boolean retryExecution() throws KeeperException, InterruptedException {
      int doneWorkers;
synchronized (LOCK) {
        doneWorkers=(int)NettyMasterCoordinator.this.iterResults.size();
      }
      if (System.nanoTime() % 30 == 0) {
        LOG.info("String_Node_Str",context.getCurrentIteration(),doneWorkers,(context.getWorkers() - doneWorkers));
      }
      boolean isTerminated=false;
      if (context.isFirstIteration() || context.getCurrentIteration() == context.getTotalIteration()) {
        isTerminated=isTerminated(doneWorkers,context.getWorkers(),context.getMinWorkersRatio(),GuaguaConstants.GUAGUA_DEFAULT_MIN_WORKERS_TIMEOUT);
        if (isTerminated) {
synchronized (LOCK) {
            NettyMasterCoordinator.this.canUpdateWorkerResultMap=false;
          }
          LOG.info("String_Node_Str",context.getCurrentIteration(),context.getWorkers(),doneWorkers,context.getMinWorkersRatio(),GuaguaConstants.GUAGUA_DEFAULT_MIN_WORKERS_TIMEOUT);
        }
      }
 else {
        isTerminated=isTerminated(doneWorkers,context.getWorkers(),context.getMinWorkersRatio(),context.getMinWorkersTimeOut());
        if (isTerminated) {
synchronized (LOCK) {
            NettyMasterCoordinator.this.canUpdateWorkerResultMap=false;
          }
          LOG.info("String_Node_Str",context.getCurrentIteration(),context.getWorkers(),doneWorkers,context.getMinWorkersRatio(),context.getMinWorkersTimeOut());
        }
      }
      return isTerminated;
    }
  }
.execute();
synchronized (LOCK) {
    this.canUpdateWorkerResultMap=false;
    this.iterResults.switchState();
  }
  if (this.iterResults instanceof BytableMemoryDiskList) {
    LOG.info("String_Node_Str",this.currentInteration,((BytableMemoryDiskList<WorkerResultWrapper>)this.iterResults).getMemoryCount());
    LOG.info("String_Node_Str",this.currentInteration,((BytableMemoryDiskList<WorkerResultWrapper>)this.iterResults).getDiskCount());
  }
 else {
    LOG.info("String_Node_Str",this.currentInteration,((MergeWorkerResultList)this.iterResults).size(),((MergeWorkerResultList)this.iterResults).mergedSize());
  }
  final int currentIter=this.currentInteration;
  context.setWorkerResults(new Iterable<WORKER_RESULT>(){
    @Override public Iterator<WORKER_RESULT> iterator(){
      return new Iterator<WORKER_RESULT>(){
        private Iterator<WorkerResultWrapper> localItr;
        private volatile AtomicBoolean isStart=new AtomicBoolean();
        WorkerResultWrapper current=null;
        @Override public boolean hasNext(){
          boolean hasNext;
synchronized (LOCK) {
            if (this.isStart.compareAndSet(false,true)) {
              this.localItr=NettyMasterCoordinator.this.iterResults.iterator();
            }
            hasNext=this.localItr.hasNext();
            if (hasNext) {
              this.current=this.localItr.next();
              while (this.current.currIter != currentIter) {
                hasNext=this.localItr.hasNext();
                if (hasNext) {
                  this.current=this.localItr.next();
                  continue;
                }
 else {
                  break;
                }
              }
            }
            if (!hasNext) {
              this.localItr=NettyMasterCoordinator.this.iterResults.iterator();
              return false;
            }
          }
          return hasNext;
        }
        @SuppressWarnings("String_Node_Str") @Override public WORKER_RESULT next(){
synchronized (LOCK) {
            return (WORKER_RESULT)this.current.workerResult;
          }
        }
        @Override public void remove(){
          throw new UnsupportedOperationException();
        }
      }
;
    }
  }
);
  LOG.info("String_Node_Str",context.getAppId(),context.getContainerId(),context.getCurrentIteration(),TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
}

Fixed version (ground truth):
/** 
 * Wait for all workers done in current iteration.
 */
@Override public void preIteration(final MasterContext<MASTER_RESULT,WORKER_RESULT> context){
synchronized (LOCK) {
    this.currentInteration=context.getCurrentIteration();
    this.canUpdateWorkerResultMap=true;
  }
  long start=System.nanoTime();
  new RetryCoordinatorCommand(isFixedTime(),getSleepTime()){
    @Override public boolean retryExecution() throws KeeperException, InterruptedException {
      int doneWorkers;
synchronized (LOCK) {
        doneWorkers=(int)NettyMasterCoordinator.this.iterResults.size();
      }
      if (System.nanoTime() % 30 == 0) {
        LOG.info("String_Node_Str",context.getCurrentIteration(),doneWorkers,(context.getWorkers() - doneWorkers));
      }
      long timeOut=0L;
      if (context.isFirstIteration() || context.getCurrentIteration() == context.getTotalIteration()) {
        timeOut=GuaguaConstants.GUAGUA_DEFAULT_MIN_WORKERS_TIMEOUT;
      }
 else {
        timeOut=context.getMinWorkersTimeOut();
      }
      boolean isTerminated=isTerminated(doneWorkers,context.getWorkers(),context.getMinWorkersRatio(),timeOut);
      if (isTerminated) {
synchronized (LOCK) {
          NettyMasterCoordinator.this.canUpdateWorkerResultMap=false;
        }
        LOG.info("String_Node_Str" + "String_Node_Str",context.getCurrentIteration(),context.getWorkers(),doneWorkers,context.getMinWorkersRatio(),GuaguaConstants.GUAGUA_DEFAULT_MIN_WORKERS_TIMEOUT);
      }
      return isTerminated;
    }
  }
.execute();
synchronized (LOCK) {
    this.canUpdateWorkerResultMap=false;
    this.iterResults.switchState();
  }
  if (this.iterResults instanceof BytableMemoryDiskList) {
    LOG.info("String_Node_Str",this.currentInteration,((BytableMemoryDiskList<WorkerResultWrapper>)this.iterResults).getMemoryCount());
    LOG.info("String_Node_Str",this.currentInteration,((BytableMemoryDiskList<WorkerResultWrapper>)this.iterResults).getDiskCount());
  }
 else {
    LOG.info("String_Node_Str",this.currentInteration,((MergeWorkerResultList)this.iterResults).size(),((MergeWorkerResultList)this.iterResults).mergedSize());
  }
  final int currentIter=this.currentInteration;
  context.setWorkerResults(new Iterable<WORKER_RESULT>(){
    @Override public Iterator<WORKER_RESULT> iterator(){
      return new Iterator<WORKER_RESULT>(){
        private Iterator<WorkerResultWrapper> localItr;
        private volatile AtomicBoolean isStart=new AtomicBoolean();
        WorkerResultWrapper current=null;
        @Override public boolean hasNext(){
          boolean hasNext;
synchronized (LOCK) {
            if (this.isStart.compareAndSet(false,true)) {
              this.localItr=NettyMasterCoordinator.this.iterResults.iterator();
            }
            hasNext=this.localItr.hasNext();
            if (hasNext) {
              this.current=this.localItr.next();
              while (this.current.currIter != currentIter) {
                hasNext=this.localItr.hasNext();
                if (hasNext) {
                  this.current=this.localItr.next();
                  continue;
                }
 else {
                  break;
                }
              }
            }
            if (!hasNext) {
              this.localItr=NettyMasterCoordinator.this.iterResults.iterator();
              return false;
            }
          }
          return hasNext;
        }
        @SuppressWarnings("String_Node_Str") @Override public WORKER_RESULT next(){
synchronized (LOCK) {
            return (WORKER_RESULT)this.current.workerResult;
          }
        }
        @Override public void remove(){
          throw new UnsupportedOperationException();
        }
      }
;
    }
  }
);
  LOG.info("String_Node_Str",context.getAppId(),context.getContainerId(),context.getCurrentIteration(),TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
}