Program: 48499
Project: 48499
Buggy source:
private void bootstrap(final AmClusterDef clusterDef,final List<String> addedHosts,final ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
  try {
    if (addedHosts != null) {
      logger.info("String_Node_Str" + addedHosts);
      clusterDef.getCurrentReport().setNodesAction("String_Node_Str",addedHosts);
      clusterDef.getCurrentReport().setProgress(ProgressSplit.BOOTSTRAP_HOSTS.getProgress());
    }
 else {
      logger.info("String_Node_Str" + clusterDef.getName());
      clusterDef.getCurrentReport().setAction("String_Node_Str");
      clusterDef.getCurrentReport().setProgress(ProgressSplit.BOOTSTRAP_HOSTS.getProgress());
    }
    reportStatus(clusterDef.getCurrentReport(),reportQueue);
    ApiBootstrap apiBootstrapRequest=apiManager.createBootstrap(clusterDef.toApiBootStrap(addedHosts));
    HostBootstrapPoller poller=new HostBootstrapPoller(apiManager,apiBootstrapRequest,clusterDef.getCurrentReport(),reportQueue,ProgressSplit.CREATE_BLUEPRINT.getProgress());
    poller.waitForComplete();
    logger.debug("String_Node_Str" + apiBootstrapRequest.getRequestId());
    boolean success=false;
    boolean allHostsBootstrapped=true;
    ApiBootstrapStatus apiBootstrapStatus=apiManager.getBootstrapStatus(apiBootstrapRequest.getRequestId());
    BootstrapStatus bootstrapStatus=BootstrapStatus.valueOf(apiBootstrapStatus.getStatus());
    logger.debug("String_Node_Str" + bootstrapStatus);
    if (!bootstrapStatus.isFailedState()) {
      success=true;
    }
    int bootstrapedHostCount=apiBootstrapStatus.getApiBootstrapHostStatus().size();
    int needBootstrapHostCount=-1;
    if (addedHosts == null) {
      needBootstrapHostCount=clusterDef.getNodes().size();
    }
 else {
      needBootstrapHostCount=addedHosts.size();
    }
    logger.debug("String_Node_Str" + needBootstrapHostCount);
    logger.debug("String_Node_Str" + bootstrapedHostCount);
    if (needBootstrapHostCount != bootstrapedHostCount) {
      success=false;
      allHostsBootstrapped=false;
    }
    if (!success) {
      List<String> notBootstrapNodes=new ArrayList<String>();
      if (!allHostsBootstrapped) {
        for (        AmNodeDef node : clusterDef.getNodes()) {
          boolean nodeBootstrapped=false;
          for (          ApiBootstrapHostStatus apiBootstrapHostStatus : apiBootstrapStatus.getApiBootstrapHostStatus()) {
            if (node.getFqdn().equals(apiBootstrapHostStatus.getHostName())) {
              nodeBootstrapped=true;
              break;
            }
          }
          if (!nodeBootstrapped) {
            notBootstrapNodes.add(node.getFqdn());
          }
        }
      }
      String actionFailure=Constants.HOST_BOOTSTRAP_MSG;
      if (addedHosts != null) {
        clusterDef.getCurrentReport().setNodesError(actionFailure,addedHosts);
      }
 else {
        clusterDef.getCurrentReport().setErrMsg(actionFailure);
      }
      throw AmException.BOOTSTRAP_FAILED(notBootstrapNodes != null ? notBootstrapNodes.toArray() : null);
    }
  }
 catch (  Exception e) {
    clusterDef.getCurrentReport().setAction(Constants.HOST_BOOTSTRAP_MSG);
    String errorMessage=errorMessage("String_Node_Str" + clusterDef.getName(),e);
    logger.error(errorMessage);
    throw AmException.BOOTSTRAP_FAILED_EXCEPTION(e,clusterDef.getName());
  }
 finally {
    reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
  }
}

Fixed version (ground truth):
private void bootstrap(final AmClusterDef clusterDef,final List<String> addedHosts,final ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
  try {
    if (addedHosts != null) {
      logger.info("String_Node_Str" + addedHosts);
      clusterDef.getCurrentReport().setNodesAction("String_Node_Str",addedHosts);
      clusterDef.getCurrentReport().setProgress(ProgressSplit.BOOTSTRAP_HOSTS.getProgress());
    }
 else {
      logger.info("String_Node_Str" + clusterDef.getName());
      clusterDef.getCurrentReport().setAction("String_Node_Str");
      clusterDef.getCurrentReport().setProgress(ProgressSplit.BOOTSTRAP_HOSTS.getProgress());
    }
    reportStatus(clusterDef.getCurrentReport(),reportQueue);
    ApiBootstrap apiBootstrapRequest=apiManager.createBootstrap(clusterDef.toApiBootStrap(addedHosts));
    HostBootstrapPoller poller=new HostBootstrapPoller(apiManager,apiBootstrapRequest,clusterDef.getCurrentReport(),reportQueue,ProgressSplit.CREATE_BLUEPRINT.getProgress());
    poller.waitForComplete();
    logger.debug("String_Node_Str" + apiBootstrapRequest.getRequestId());
    boolean success=false;
    boolean allHostsBootstrapped=true;
    ApiBootstrapStatus apiBootstrapStatus=apiManager.getBootstrapStatus(apiBootstrapRequest.getRequestId());
    BootstrapStatus bootstrapStatus=BootstrapStatus.valueOf(apiBootstrapStatus.getStatus());
    logger.debug("String_Node_Str" + bootstrapStatus);
    if (!bootstrapStatus.isFailedState()) {
      success=true;
    }
    int bootstrapedHostCount=apiBootstrapStatus.getApiBootstrapHostStatus().size();
    int needBootstrapHostCount=-1;
    if (addedHosts == null) {
      needBootstrapHostCount=clusterDef.getNodes().size();
    }
 else {
      needBootstrapHostCount=addedHosts.size();
    }
    logger.debug("String_Node_Str" + needBootstrapHostCount);
    logger.debug("String_Node_Str" + bootstrapedHostCount);
    if (needBootstrapHostCount != bootstrapedHostCount) {
      success=false;
      allHostsBootstrapped=false;
    }
    if (!success) {
      List<String> notBootstrapNodes=new ArrayList<String>();
      if (!allHostsBootstrapped) {
        for (        AmNodeDef node : clusterDef.getNodes()) {
          boolean nodeBootstrapped=false;
          for (          ApiBootstrapHostStatus apiBootstrapHostStatus : apiBootstrapStatus.getApiBootstrapHostStatus()) {
            if (node.getFqdn().equals(apiBootstrapHostStatus.getHostName())) {
              nodeBootstrapped=true;
              break;
            }
          }
          if (!nodeBootstrapped) {
            notBootstrapNodes.add(node.getFqdn());
          }
        }
      }
      setBootstrapNodeError(clusterDef,addedHosts);
      throw AmException.BOOTSTRAP_FAILED(notBootstrapNodes != null ? notBootstrapNodes.toArray() : null);
    }
  }
 catch (  Exception e) {
    setBootstrapNodeError(clusterDef,addedHosts);
    String errorMessage=errorMessage("String_Node_Str" + clusterDef.getName(),e);
    logger.error(errorMessage);
    throw AmException.BOOTSTRAP_FAILED_EXCEPTION(e,clusterDef.getName());
  }
 finally {
    reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
  }
}