Program: 105445
Project: 105445
Buggy source:
@Override public void scheduleRestartForVmsOnHost(final HostVO host,boolean investigate){
  if (host.getType() != Host.Type.Routing) {
    return;
  }
  if (host.getHypervisorType() == HypervisorType.VMware || host.getHypervisorType() == HypervisorType.Hyperv) {
    s_logger.info("String_Node_Str" + host.getId() + "String_Node_Str");
    return;
  }
  s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName());
  final List<VMInstanceVO> vms=_instanceDao.listByHostId(host.getId());
  final DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
  StringBuilder sb=null;
  if ((vms != null) && !vms.isEmpty()) {
    sb=new StringBuilder();
    sb.append("String_Node_Str");
    VMInstanceVO vm=vms.get(0);
    if (vm.isHaEnabled()) {
      sb.append("String_Node_Str" + vm);
    }
    for (int i=1; i < vms.size(); i++) {
      vm=vms.get(i);
      if (vm.isHaEnabled()) {
        sb.append("String_Node_Str" + vm.getHostName());
      }
    }
  }
  HostPodVO podVO=_podDao.findById(host.getPodId());
  String hostDesc="String_Node_Str" + host.getName() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ dcVO.getName()+ "String_Node_Str"+ podVO.getName();
  _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST,host.getDataCenterId(),host.getPodId(),"String_Node_Str" + hostDesc,"String_Node_Str" + hostDesc + "String_Node_Str"+ ((sb != null) ? sb.toString() : "String_Node_Str"));
  for (  VMInstanceVO vm : vms) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + vm.getId() + "String_Node_Str"+ vm.getInstanceName());
    }
    vm=_instanceDao.findByUuid(vm.getUuid());
    Long hostId=vm.getHostId();
    if (hostId != null && !hostId.equals(host.getId())) {
      s_logger.debug("String_Node_Str" + vm.getInstanceName() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ hostId+ "String_Node_Str");
      continue;
    }
    scheduleRestart(vm,investigate);
  }
}

Fixed version (ground truth):
@Override public void scheduleRestartForVmsOnHost(final HostVO host,boolean investigate){
  if (host.getType() != Host.Type.Routing) {
    return;
  }
  if (host.getHypervisorType() == HypervisorType.VMware || host.getHypervisorType() == HypervisorType.Hyperv) {
    s_logger.info("String_Node_Str" + host.getId() + "String_Node_Str");
    return;
  }
  s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName());
  final List<VMInstanceVO> vms=_instanceDao.listByHostId(host.getId());
  final DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
  StringBuilder sb=null;
  if ((vms != null) && !vms.isEmpty()) {
    sb=new StringBuilder();
    sb.append("String_Node_Str");
    VMInstanceVO vm=vms.get(0);
    if (vm.isHaEnabled()) {
      sb.append("String_Node_Str" + vm);
    }
    for (int i=1; i < vms.size(); i++) {
      vm=vms.get(i);
      if (vm.isHaEnabled()) {
        sb.append("String_Node_Str" + vm.getHostName());
      }
    }
  }
  HostPodVO podVO=_podDao.findById(host.getPodId());
  String hostDesc="String_Node_Str" + host.getName() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ dcVO.getName()+ "String_Node_Str"+ podVO.getName();
  _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST,host.getDataCenterId(),host.getPodId(),"String_Node_Str" + hostDesc,"String_Node_Str" + hostDesc + "String_Node_Str"+ ((sb != null) ? sb.toString() : "String_Node_Str"));
  if (vms != null) {
    for (    VMInstanceVO vm : vms) {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + vm.getId() + "String_Node_Str"+ vm.getInstanceName());
      }
      vm=_instanceDao.findByUuid(vm.getUuid());
      Long hostId=vm.getHostId();
      if (hostId != null && !hostId.equals(host.getId())) {
        s_logger.debug("String_Node_Str" + vm.getInstanceName() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ hostId+ "String_Node_Str");
        continue;
      }
      scheduleRestart(vm,investigate);
    }
  }
}