Program: 105669
Project: 105669
Buggy source:
private void processReport(long hostId,Map<Long,VirtualMachine.PowerState> translatedInfo){
  if (s_logger.isDebugEnabled())   s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ translatedInfo.size());
  for (  Map.Entry<Long,VirtualMachine.PowerState> entry : translatedInfo.entrySet()) {
    if (s_logger.isDebugEnabled())     s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ entry.getKey()+ "String_Node_Str"+ entry.getValue());
    if (_instanceDao.updatePowerState(entry.getKey(),hostId,entry.getValue())) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ entry.getKey()+ "String_Node_Str"+ entry.getValue());
      _messageBus.publish(null,VirtualMachineManager.Topics.VM_POWER_STATE,PublishScope.GLOBAL,entry.getKey());
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + entry.getKey());
    }
  }
  List<VMInstanceVO> vmsThatAreMissingReport=_instanceDao.findByHostInStates(hostId,VirtualMachine.State.Running,VirtualMachine.State.Stopping,VirtualMachine.State.Starting);
  java.util.Iterator<VMInstanceVO> it=vmsThatAreMissingReport.iterator();
  while (it.hasNext()) {
    VMInstanceVO instance=it.next();
    if (translatedInfo.get(instance.getId()) != null)     it.remove();
  }
  if (vmsThatAreMissingReport.size() > 0) {
    Date currentTime=DateUtil.currentGMTTime();
    if (s_logger.isDebugEnabled())     s_logger.debug("String_Node_Str" + currentTime.getTime());
    long milliSecondsGracefullPeriod=PingInterval.value() * 2000;
    for (    VMInstanceVO instance : vmsThatAreMissingReport) {
      Date vmStateUpdateTime=instance.getUpdateTime();
      if (vmStateUpdateTime == null) {
        s_logger.warn("String_Node_Str" + instance.getId());
        vmStateUpdateTime=currentTime;
      }
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ instance.getId()+ "String_Node_Str"+ vmStateUpdateTime.getTime());
      long milliSecondsSinceLastStateUpdate=currentTime.getTime() - vmStateUpdateTime.getTime();
      if (milliSecondsSinceLastStateUpdate > milliSecondsGracefullPeriod) {
        s_logger.debug("String_Node_Str" + instance.getId() + "String_Node_Str"+ milliSecondsSinceLastStateUpdate+ "String_Node_Str");
        if (_instanceDao.updatePowerState(instance.getId(),hostId,VirtualMachine.PowerState.PowerReportMissing)) {
          if (s_logger.isDebugEnabled())           s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ instance.getId()+ "String_Node_Str");
          _messageBus.publish(null,VirtualMachineManager.Topics.VM_POWER_STATE,PublishScope.GLOBAL,instance.getId());
        }
 else {
          if (s_logger.isDebugEnabled())           s_logger.debug("String_Node_Str" + instance.getId());
        }
      }
 else {
        s_logger.debug("String_Node_Str" + instance.getId() + "String_Node_Str"+ milliSecondsSinceLastStateUpdate+ "String_Node_Str");
      }
    }
  }
  if (s_logger.isDebugEnabled())   s_logger.debug("String_Node_Str" + hostId);
}

Fixed version (ground truth):
private void processReport(long hostId,Map<Long,VirtualMachine.PowerState> translatedInfo){
  if (s_logger.isDebugEnabled())   s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ translatedInfo.size());
  for (  Map.Entry<Long,VirtualMachine.PowerState> entry : translatedInfo.entrySet()) {
    if (s_logger.isDebugEnabled())     s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ entry.getKey()+ "String_Node_Str"+ entry.getValue());
    if (_instanceDao.updatePowerState(entry.getKey(),hostId,entry.getValue())) {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ entry.getKey()+ "String_Node_Str"+ entry.getValue());
      _messageBus.publish(null,VirtualMachineManager.Topics.VM_POWER_STATE,PublishScope.GLOBAL,entry.getKey());
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + entry.getKey());
    }
  }
  List<VMInstanceVO> vmsThatAreMissingReport=_instanceDao.findByHostInStates(hostId,VirtualMachine.State.Running,VirtualMachine.State.Stopping,VirtualMachine.State.Starting);
  java.util.Iterator<VMInstanceVO> it=vmsThatAreMissingReport.iterator();
  while (it.hasNext()) {
    VMInstanceVO instance=it.next();
    if (translatedInfo.get(instance.getId()) != null)     it.remove();
  }
  if (vmsThatAreMissingReport.size() > 0) {
    Date currentTime=DateUtil.currentGMTTime();
    if (s_logger.isDebugEnabled())     s_logger.debug("String_Node_Str" + currentTime.getTime());
    long milliSecondsGracefullPeriod=PingInterval.value() * 2000L;
    for (    VMInstanceVO instance : vmsThatAreMissingReport) {
      Date vmStateUpdateTime=instance.getUpdateTime();
      if (vmStateUpdateTime == null) {
        s_logger.warn("String_Node_Str" + instance.getId());
        vmStateUpdateTime=currentTime;
      }
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ instance.getId()+ "String_Node_Str"+ vmStateUpdateTime.getTime());
      long milliSecondsSinceLastStateUpdate=currentTime.getTime() - vmStateUpdateTime.getTime();
      if (milliSecondsSinceLastStateUpdate > milliSecondsGracefullPeriod) {
        s_logger.debug("String_Node_Str" + instance.getId() + "String_Node_Str"+ milliSecondsSinceLastStateUpdate+ "String_Node_Str");
        if (_instanceDao.updatePowerState(instance.getId(),hostId,VirtualMachine.PowerState.PowerReportMissing)) {
          if (s_logger.isDebugEnabled())           s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ instance.getId()+ "String_Node_Str");
          _messageBus.publish(null,VirtualMachineManager.Topics.VM_POWER_STATE,PublishScope.GLOBAL,instance.getId());
        }
 else {
          if (s_logger.isDebugEnabled())           s_logger.debug("String_Node_Str" + instance.getId());
        }
      }
 else {
        s_logger.debug("String_Node_Str" + instance.getId() + "String_Node_Str"+ milliSecondsSinceLastStateUpdate+ "String_Node_Str");
      }
    }
  }
  if (s_logger.isDebugEnabled())   s_logger.debug("String_Node_Str" + hostId);
}