Program: 106915
Project: 106915
Buggy source:
protected boolean rebalanceHost(final long hostId,long currentOwnerId,long futureOwnerId) throws AgentUnavailableException {
  boolean result=true;
  if (currentOwnerId == _nodeId) {
    _agentToTransferIds.remove(hostId);
    if (!startRebalance(hostId)) {
      s_logger.debug("String_Node_Str");
      failRebalance(hostId);
      return false;
    }
    try {
      Answer[] answer=sendRebalanceCommand(futureOwnerId,hostId,currentOwnerId,futureOwnerId,Event.StartAgentRebalance);
      if (answer == null || !answer[0].getResult()) {
        s_logger.warn("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId+ "String_Node_Str");
        result=false;
      }
    }
 catch (    Exception ex) {
      s_logger.warn("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId+ "String_Node_Str",ex);
      result=false;
    }
    if (result) {
      s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId);
      finishRebalance(hostId,futureOwnerId,Event.RebalanceCompleted);
    }
 else {
      finishRebalance(hostId,futureOwnerId,Event.RebalanceFailed);
    }
  }
 else   if (futureOwnerId == _nodeId) {
    HostVO host=_hostDao.findById(hostId);
    try {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName()+ "String_Node_Str");
      }
      result=loadDirectlyConnectedHost(host,true);
    }
 catch (    Exception ex) {
      s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str",ex);
      result=false;
    }
  }
  return result;
}

Fixed version (ground truth):
protected boolean rebalanceHost(final long hostId,long currentOwnerId,long futureOwnerId) throws AgentUnavailableException {
  boolean result=true;
  if (currentOwnerId == _nodeId) {
    if (!startRebalance(hostId)) {
      s_logger.debug("String_Node_Str");
      failRebalance(hostId);
      return false;
    }
    try {
      Answer[] answer=sendRebalanceCommand(futureOwnerId,hostId,currentOwnerId,futureOwnerId,Event.StartAgentRebalance);
      if (answer == null || !answer[0].getResult()) {
        s_logger.warn("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId+ "String_Node_Str");
        result=false;
      }
    }
 catch (    Exception ex) {
      s_logger.warn("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId+ "String_Node_Str",ex);
      result=false;
    }
    if (result) {
      s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId);
      finishRebalance(hostId,futureOwnerId,Event.RebalanceCompleted);
    }
 else {
      s_logger.debug("String_Node_Str" + hostId + "String_Node_Str"+ futureOwnerId);
      finishRebalance(hostId,futureOwnerId,Event.RebalanceFailed);
    }
  }
 else   if (futureOwnerId == _nodeId) {
    HostVO host=_hostDao.findById(hostId);
    try {
      if (s_logger.isDebugEnabled()) {
        s_logger.debug("String_Node_Str" + host.getId() + "String_Node_Str"+ host.getName()+ "String_Node_Str");
      }
      result=loadDirectlyConnectedHost(host,true);
    }
 catch (    Exception ex) {
      s_logger.warn("String_Node_Str" + host.getId() + "String_Node_Str",ex);
      result=false;
    }
  }
  return result;
}