Program: 106934
Project: 106934
Buggy source:
@Override public void scheduleRestart(VMInstanceVO vm,final boolean investigate){
  Long hostId=vm.getHostId();
  if (hostId == null) {
    _itMgr.stateTransitTo(vm,Event.OperationFailed,null);
    return;
  }
  if (!investigate) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + vm.toString());
    }
    short alertType=AlertManager.ALERT_TYPE_USERVM;
    if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
      alertType=AlertManager.ALERT_TYPE_DOMAIN_ROUTER;
    }
 else     if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
      alertType=AlertManager.ALERT_TYPE_CONSOLE_PROXY;
    }
    if (!(_forceHA || vm.isHaEnabled())) {
      String hostDesc="String_Node_Str" + vm.getHostId() + "String_Node_Str"+ vm.getDataCenterIdToDeployIn()+ "String_Node_Str"+ vm.getPodIdToDeployIn();
      _alertMgr.sendAlert(alertType,vm.getDataCenterIdToDeployIn(),vm.getPodIdToDeployIn(),"String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getId()+ "String_Node_Str"+ hostDesc,"String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getId()+ "String_Node_Str"+ vm.getHostId()+ "String_Node_Str");
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str");
      }
    }
    try {
      _itMgr.advanceStop(vm,true,_accountMgr.getSystemUser(),_accountMgr.getSystemAccount());
    }
 catch (    ResourceUnavailableException e) {
    }
catch (    OperationTimedoutException e) {
    }
catch (    ConcurrentOperationException e) {
    }
  }
  List<HaWorkVO> items=_haDao.findPreviousHA(vm.getId());
  int maxRetries=0;
  for (  HaWorkVO item : items) {
    if (maxRetries < item.getTimesTried() && !item.canScheduleNew(_timeBetweenFailures)) {
      maxRetries=item.getTimesTried();
      break;
    }
  }
  HaWorkVO work=new HaWorkVO(vm.getId(),vm.getType(),WorkType.HA,investigate ? Step.Investigating : Step.Scheduled,hostId,vm.getState(),maxRetries + 1,vm.getUpdated());
  _haDao.persist(work);
  if (s_logger.isInfoEnabled()) {
    s_logger.info("String_Node_Str" + vm);
  }
  wakeupWorkers();
}

Fixed version (ground truth):
@Override public void scheduleRestart(VMInstanceVO vm,boolean investigate){
  Long hostId=vm.getHostId();
  if (hostId == null) {
    try {
      s_logger.debug("String_Node_Str" + vm);
      _itMgr.stateTransitTo(vm,Event.OperationFailed,null);
    }
 catch (    NoTransitionException e) {
    }
    return;
  }
  if (!investigate) {
    if (s_logger.isDebugEnabled()) {
      s_logger.debug("String_Node_Str" + vm.toString());
    }
    short alertType=AlertManager.ALERT_TYPE_USERVM;
    if (VirtualMachine.Type.DomainRouter.equals(vm.getType())) {
      alertType=AlertManager.ALERT_TYPE_DOMAIN_ROUTER;
    }
 else     if (VirtualMachine.Type.ConsoleProxy.equals(vm.getType())) {
      alertType=AlertManager.ALERT_TYPE_CONSOLE_PROXY;
    }
    if (!(_forceHA || vm.isHaEnabled())) {
      String hostDesc="String_Node_Str" + vm.getHostId() + "String_Node_Str"+ vm.getDataCenterIdToDeployIn()+ "String_Node_Str"+ vm.getPodIdToDeployIn();
      _alertMgr.sendAlert(alertType,vm.getDataCenterIdToDeployIn(),vm.getPodIdToDeployIn(),"String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getId()+ "String_Node_Str"+ hostDesc,"String_Node_Str" + vm.getHostName() + "String_Node_Str"+ vm.getId()+ "String_Node_Str"+ vm.getHostId()+ "String_Node_Str");
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str");
      }
    }
    try {
      _itMgr.advanceStop(vm,true,_accountMgr.getSystemUser(),_accountMgr.getSystemAccount());
    }
 catch (    ResourceUnavailableException e) {
    }
catch (    OperationTimedoutException e) {
    }
catch (    ConcurrentOperationException e) {
    }
  }
  List<HaWorkVO> items=_haDao.findPreviousHA(vm.getId());
  int maxRetries=0;
  for (  HaWorkVO item : items) {
    if (maxRetries < item.getTimesTried() && !item.canScheduleNew(_timeBetweenFailures)) {
      maxRetries=item.getTimesTried();
      break;
    }
  }
  HaWorkVO work=new HaWorkVO(vm.getId(),vm.getType(),WorkType.HA,investigate ? Step.Investigating : Step.Scheduled,hostId,vm.getState(),maxRetries + 1,vm.getUpdated());
  _haDao.persist(work);
  if (s_logger.isInfoEnabled()) {
    s_logger.info("String_Node_Str" + vm);
  }
  wakeupWorkers();
}