Program: 48482
Project: 48482
Buggy source:
private void provisionWithBlueprint(final AmClusterDef clusterDef,final ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
  try {
    logger.info("String_Node_Str" + clusterDef.getName() + "String_Node_Str"+ clusterDef.getName());
    clusterDef.getCurrentReport().setAction("String_Node_Str");
    clusterDef.getCurrentReport().setProgress(ProgressSplit.PROVISION_CLUSTER.getProgress());
    reportStatus(clusterDef.getCurrentReport(),reportQueue);
    String clusterName=clusterDef.getName();
    ReflectionUtils.getPreStartServicesHook().preStartServices(clusterName,120);
    if (isProvisioned(clusterName) && isClusterProvisionedByBDE(clusterDef)) {
      try {
        if (hasHosts(clusterName)) {
          ApiRequest apiRequestSummary=apiManager.stopAllServicesInCluster(clusterName);
          doSoftwareOperation(clusterName,apiRequestSummary,clusterDef.getCurrentReport(),reportQueue);
        }
      }
 catch (      Exception e) {
        String errMsg=getErrorMsg("String_Node_Str",e);
        logger.error(errMsg,e);
        throw SoftwareManagementPluginException.STOP_CLUSTER_EXCEPTION(e,Constants.AMBARI_PLUGIN_NAME,clusterName);
      }
      apiManager.deleteCluster(clusterName);
    }
    ApiRequest apiRequestSummary=apiManager.provisionCluster(clusterDef.getName(),clusterDef.toApiClusterBlueprint());
    ClusterOperationPoller poller=new ClusterOperationPoller(apiManager,apiRequestSummary,clusterName,clusterDef.getCurrentReport(),reportQueue,ProgressSplit.PROVISION_SUCCESS.getProgress());
    poller.waitForComplete();
    boolean success=false;
    ApiRequest apiRequest=apiManager.getRequest(clusterName,apiRequestSummary.getApiRequestInfo().getRequestId());
    ClusterRequestStatus clusterRequestStatus=ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo().getRequestStatus());
    if (!clusterRequestStatus.isFailedState()) {
      success=true;
    }
    if (!success) {
      throw SoftwareManagementPluginException.CREATE_CLUSTER_FAIL(Constants.AMBARI_PLUGIN_NAME,clusterDef.getName());
    }
  }
 catch (  Exception e) {
    clusterDef.getCurrentReport().setAction("String_Node_Str");
    String errorMessage=errorMessage("String_Node_Str" + clusterDef.getName() + "String_Node_Str",e);
    logger.error(errorMessage);
    throw AmException.PROVISION_WITH_BLUEPRINT_FAILED(e,clusterDef.getName());
  }
 finally {
    reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
  }
}

Fixed version (ground truth):
private void provisionWithBlueprint(final AmClusterDef clusterDef,final ClusterReportQueue reportQueue) throws SoftwareManagementPluginException {
  try {
    logger.info("String_Node_Str" + clusterDef.getName() + "String_Node_Str"+ clusterDef.getName());
    clusterDef.getCurrentReport().setAction("String_Node_Str");
    clusterDef.getCurrentReport().setProgress(ProgressSplit.PROVISION_CLUSTER.getProgress());
    reportStatus(clusterDef.getCurrentReport(),reportQueue);
    String clusterName=clusterDef.getName();
    ReflectionUtils.getPreStartServicesHook().preStartServices(clusterName,120);
    if (isProvisioned(clusterName) && isClusterProvisionedByBDE(clusterDef)) {
      try {
        if (hasHosts(clusterName)) {
          ApiRequest apiRequestSummary=apiManager.stopAllServicesInCluster(clusterName);
          doSoftwareOperation(clusterName,apiRequestSummary,clusterDef.getCurrentReport(),reportQueue);
        }
      }
 catch (      Exception e) {
        logger.error("String_Node_Str",e);
        throw SoftwareManagementPluginException.STOP_CLUSTER_EXCEPTION(e,Constants.AMBARI_PLUGIN_NAME,clusterName);
      }
      apiManager.deleteCluster(clusterName);
    }
    ApiRequest apiRequestSummary=apiManager.provisionCluster(clusterDef.getName(),clusterDef.toApiClusterBlueprint());
    ClusterOperationPoller poller=new ClusterOperationPoller(apiManager,apiRequestSummary,clusterName,clusterDef.getCurrentReport(),reportQueue,ProgressSplit.PROVISION_SUCCESS.getProgress());
    poller.waitForComplete();
    boolean success=false;
    ApiRequest apiRequest=apiManager.getRequest(clusterName,apiRequestSummary.getApiRequestInfo().getRequestId());
    ClusterRequestStatus clusterRequestStatus=ClusterRequestStatus.valueOf(apiRequest.getApiRequestInfo().getRequestStatus());
    if (!clusterRequestStatus.isFailedState()) {
      success=true;
    }
    if (!success) {
      throw SoftwareManagementPluginException.CREATE_CLUSTER_FAIL(Constants.AMBARI_PLUGIN_NAME,clusterDef.getName());
    }
  }
 catch (  Exception e) {
    clusterDef.getCurrentReport().setAction("String_Node_Str");
    String errorMessage=errorMessage("String_Node_Str" + clusterDef.getName() + "String_Node_Str",e);
    logger.error(errorMessage);
    throw AmException.PROVISION_WITH_BLUEPRINT_FAILED(e,clusterDef.getName());
  }
 finally {
    reportQueue.addClusterReport(clusterDef.getCurrentReport().clone());
  }
}