Program: 105954
Project: 105954
Buggy source:
protected boolean handleDisconnectWithInvestigation(AgentAttache attache,Status.Event event){
  long hostId=attache.getId();
  HostVO host=_hostDao.findById(hostId);
  if (host != null) {
    Status nextStatus=null;
    try {
      nextStatus=host.getStatus().getNextStatus(event);
    }
 catch (    NoTransitionException ne) {
    }
    if (nextStatus == Status.Alert) {
      s_logger.info("String_Node_Str" + hostId + "String_Node_Str"+ event);
      final Status determinedState=investigate(attache);
      if (determinedState == null) {
        s_logger.warn("String_Node_Str");
        return false;
      }
      final Status currentStatus=host.getStatus();
      s_logger.info("String_Node_Str" + determinedState);
      if (determinedState == Status.Down) {
        s_logger.error("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName()+ "String_Node_Str");
        event=Status.Event.HostDown;
      }
 else       if (determinedState == Status.Up) {
        s_logger.info("String_Node_Str");
        agentStatusTransitTo(host,Status.Event.Ping,_nodeId);
        return false;
      }
 else       if (determinedState == Status.Disconnected) {
        s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName());
        if (currentStatus == Status.Disconnected) {
          if (((System.currentTimeMillis() >> 10) - host.getLastPinged()) > AlertWait.value()) {
            s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str");
            event=Status.Event.WaitedTooLong;
          }
 else {
            s_logger.debug("String_Node_Str");
            return false;
          }
        }
 else         if (currentStatus == Status.Up) {
          DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
          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();
          if ((host.getType() != Host.Type.SecondaryStorage) && (host.getType() != Host.Type.ConsoleProxy)) {
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST,host.getDataCenterId(),host.getPodId(),"String_Node_Str" + hostDesc,"String_Node_Str" + hostDesc + "String_Node_Str"+ AlertWait+ "String_Node_Str");
          }
          event=Status.Event.AgentDisconnected;
        }
      }
 else {
        DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
        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" + host.getDataCenterId() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ host.getName());
      }
    }
 else {
      s_logger.debug("String_Node_Str" + host.getId() + "String_Node_Str");
    }
  }
  handleDisconnectWithoutInvestigation(attache,event,true,true);
  host=_hostDao.findById(host.getId());
  if (host.getStatus() == Status.Alert || host.getStatus() == Status.Down) {
    _haMgr.scheduleRestartForVmsOnHost(host,true);
  }
  return true;
}

Fixed version (ground truth):
protected boolean handleDisconnectWithInvestigation(AgentAttache attache,Status.Event event){
  long hostId=attache.getId();
  HostVO host=_hostDao.findById(hostId);
  if (host != null) {
    Status nextStatus=null;
    try {
      nextStatus=host.getStatus().getNextStatus(event);
    }
 catch (    NoTransitionException ne) {
    }
    if (nextStatus == Status.Alert) {
      s_logger.info("String_Node_Str" + hostId + "String_Node_Str"+ event);
      final Status determinedState=investigate(attache);
      if (determinedState == null) {
        s_logger.warn("String_Node_Str");
        return false;
      }
      final Status currentStatus=host.getStatus();
      s_logger.info("String_Node_Str" + determinedState);
      if (determinedState == Status.Down) {
        s_logger.error("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName()+ "String_Node_Str");
        event=Status.Event.HostDown;
      }
 else       if (determinedState == Status.Up) {
        s_logger.info("String_Node_Str");
        agentStatusTransitTo(host,Status.Event.Ping,_nodeId);
        return false;
      }
 else       if (determinedState == Status.Disconnected) {
        s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName());
        if (currentStatus == Status.Disconnected) {
          if (((System.currentTimeMillis() >> 10) - host.getLastPinged()) > AlertWait.value()) {
            s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str");
            event=Status.Event.WaitedTooLong;
          }
 else {
            s_logger.debug("String_Node_Str");
            return false;
          }
        }
 else         if (currentStatus == Status.Up) {
          DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
          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();
          if ((host.getType() != Host.Type.SecondaryStorage) && (host.getType() != Host.Type.ConsoleProxy)) {
            _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST,host.getDataCenterId(),host.getPodId(),"String_Node_Str" + hostDesc,"String_Node_Str" + hostDesc + "String_Node_Str"+ AlertWait+ "String_Node_Str");
          }
          event=Status.Event.AgentDisconnected;
        }
      }
 else {
        DataCenterVO dcVO=_dcDao.findById(host.getDataCenterId());
        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" + host.getDataCenterId() + "String_Node_Str"+ host.getId()+ "String_Node_Str"+ host.getName());
      }
    }
 else {
      s_logger.debug("String_Node_Str" + host.getId() + "String_Node_Str");
    }
  }
  handleDisconnectWithoutInvestigation(attache,event,true,true);
  host=_hostDao.findById(hostId);
  if (host != null && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) {
    _haMgr.scheduleRestartForVmsOnHost(host,true);
  }
  return true;
}