Program: 80301
Project: 80301
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()){
    /** 
 * Next index to for logging
 */
    private int nextIndex=0;
    @Override public boolean retryExecution() throws KeeperException, InterruptedException {
      int doneWorkers;
synchronized (LOCK) {
        doneWorkers=(int)NettyMasterCoordinator.this.iterResults.size();
      }
      int[] dumpArray={context.getWorkers() / 5,context.getWorkers() * 2 / 5,context.getWorkers() * 3 / 5,context.getWorkers() * 4 / 5,context.getWorkers()};
      for (int i=nextIndex; i < dumpArray.length; i++) {
        if (doneWorkers >= dumpArray[i]) {
          nextIndex=i + 1;
          LOG.info("String_Node_Str",context.getCurrentIteration(),doneWorkers,(context.getWorkers() - doneWorkers));
        }
      }
      if (System.nanoTime() % 100 == 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));
}

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()){
    /** 
 * Next index to for logging
 */
    private int nextIndex=0;
    @Override public boolean retryExecution() throws KeeperException, InterruptedException {
      int doneWorkers;
synchronized (LOCK) {
        doneWorkers=(int)NettyMasterCoordinator.this.iterResults.size();
      }
      int[] dumpArray={context.getWorkers() / 4,context.getWorkers() * 2 / 4,context.getWorkers() * 3 / 4,context.getWorkers()};
      for (int i=nextIndex; i < dumpArray.length; i++) {
        if (doneWorkers >= dumpArray[i]) {
          nextIndex=i + 1;
          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));
}