Program: 48880
Project: 48880
Buggy source:
public Long createCluster(ClusterCreate createSpec) throws Exception {
  if (CommonUtil.isBlank(createSpec.getDistro())) {
    setDefaultDistro(createSpec);
  }
  DistroRead distroRead=getDistroManager().getDistroByName(createSpec.getDistro());
  createSpec.setDistroVendor(distroRead.getVendor());
  createSpec.setDistroVersion(distroRead.getVersion());
  createAutoRps(createSpec);
  ClusterCreate clusterSpec=ClusterSpecFactory.getCustomizedSpec(createSpec);
  if (clusterSpec != null && clusterSpec.getNodeGroups() != null) {
    for (    NodeGroupCreate ng : clusterSpec.getNodeGroups()) {
      String templateVmId=clusteringService.getTemplateVmId();
      if (templateVmId != null) {
        VcResourceUtils.checkVmMaxConfiguration(templateVmId,ng.getCpuNum(),ng.getMemCapacityMB());
      }
    }
  }
  String name=clusterSpec.getName();
  logger.info("String_Node_Str" + name);
  List<String> dsNames=getUsedDS(clusterSpec.getDsNames());
  if (dsNames.isEmpty()) {
    throw ClusterConfigException.NO_DATASTORE_ADDED();
  }
  List<VcCluster> vcClusters=getUsedVcClusters(clusterSpec.getRpNames());
  if (vcClusters == null || vcClusters.isEmpty()) {
    throw ClusterConfigException.NO_RESOURCE_POOL_ADDED();
  }
  validateDatastore(dsNames,vcClusters);
  validateNetworkAccessibility(createSpec.getNetworkNames(),vcClusters);
  clusterConfigMgr.createClusterConfig(clusterSpec);
  clusterEntityMgr.updateClusterStatus(name,ClusterStatus.PROVISIONING);
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_SUCCESS_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.PROVISION_ERROR.name()));
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(createSpec.getName()));
  param.put(JobConstants.VERIFY_NODE_STATUS_SCOPE_PARAM,new JobParameter(JobConstants.CLUSTER_NODE_SCOPE_VALUE));
  JobParameters jobParameters=new JobParameters(param);
  return jobManager.runJob(JobConstants.CREATE_CLUSTER_JOB_NAME,jobParameters);
}

Fixed version (ground truth):
public Long createCluster(ClusterCreate createSpec) throws Exception {
  if (CommonUtil.isBlank(createSpec.getDistro())) {
    setDefaultDistro(createSpec);
  }
  DistroRead distroRead=getDistroManager().getDistroByName(createSpec.getDistro());
  createSpec.setDistroVendor(distroRead.getVendor());
  createSpec.setDistroVersion(distroRead.getVersion());
  createAutoRps(createSpec);
  ClusterCreate clusterSpec=ClusterSpecFactory.getCustomizedSpec(createSpec);
  clusterSpec.validateNodeGroupNames();
  if (clusterSpec != null && clusterSpec.getNodeGroups() != null) {
    for (    NodeGroupCreate ng : clusterSpec.getNodeGroups()) {
      String templateVmId=clusteringService.getTemplateVmId();
      if (templateVmId != null) {
        VcResourceUtils.checkVmMaxConfiguration(templateVmId,ng.getCpuNum(),ng.getMemCapacityMB());
      }
    }
  }
  String name=clusterSpec.getName();
  logger.info("String_Node_Str" + name);
  List<String> dsNames=getUsedDS(clusterSpec.getDsNames());
  if (dsNames.isEmpty()) {
    throw ClusterConfigException.NO_DATASTORE_ADDED();
  }
  List<VcCluster> vcClusters=getUsedVcClusters(clusterSpec.getRpNames());
  if (vcClusters == null || vcClusters.isEmpty()) {
    throw ClusterConfigException.NO_RESOURCE_POOL_ADDED();
  }
  validateDatastore(dsNames,vcClusters);
  validateNetworkAccessibility(createSpec.getNetworkNames(),vcClusters);
  clusterConfigMgr.createClusterConfig(clusterSpec);
  clusterEntityMgr.updateClusterStatus(name,ClusterStatus.PROVISIONING);
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_SUCCESS_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.PROVISION_ERROR.name()));
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(createSpec.getName()));
  param.put(JobConstants.VERIFY_NODE_STATUS_SCOPE_PARAM,new JobParameter(JobConstants.CLUSTER_NODE_SCOPE_VALUE));
  JobParameters jobParameters=new JobParameters(param);
  return jobManager.runJob(JobConstants.CREATE_CLUSTER_JOB_NAME,jobParameters);
}