Program: 48589
Project: 48589
Buggy source:
public Long createCluster(ClusterCreate createSpec) throws Exception {
  SoftwareManager softMgr=softwareManagerCollector.getSoftwareManager(createSpec.getAppManager());
  HadoopStack stack=clusterConfigMgr.filterDistroFromAppManager(softMgr,createSpec.getDistro());
  createSpec.setDistroVendor(stack.getVendor());
  createSpec.setDistroVersion(stack.getFullVersion());
  createAutoRps(createSpec);
  ClusterCreate clusterSpec=ClusterSpecFactory.getCustomizedSpec(createSpec);
  createSpec.verifyClusterNameLength();
  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() == null ? 0 : ng.getCpuNum(),ng.getMemCapacityMB() == null ? 0 : 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 {
  SoftwareManager softMgr=softwareManagerCollector.getSoftwareManager(createSpec.getAppManager());
  HadoopStack stack=clusterConfigMgr.filterDistroFromAppManager(softMgr,createSpec.getDistro());
  createSpec.setDistroVendor(stack.getVendor());
  createSpec.setDistroVersion(stack.getFullVersion());
  createAutoRps(createSpec);
  ClusterCreate clusterSpec=ClusterSpecFactory.getCustomizedSpec(createSpec,softMgr.getType());
  createSpec.verifyClusterNameLength();
  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() == null ? 0 : ng.getCpuNum(),ng.getMemCapacityMB() == null ? 0 : 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);
}