Program: 48968
Project: 48968
Buggy source:
/** 
 * set cluster parameters asynchronously
 * @param clusterName
 * @param enableManualElasticity
 * @param activeComputeNodeNum
 * @return
 * @throws Exception
 */
public Long asyncSetParam(String clusterName,Integer activeComputeNodeNum,Integer minComputeNodeNum,Boolean enableAuto,Priority ioPriority) throws Exception {
  ClusterRead cluster=getClusterByName(clusterName,false);
  if (!ClusterStatus.RUNNING.equals(cluster.getStatus())) {
    String msg="String_Node_Str";
    logger.error(msg);
    throw ClusterManagerException.SET_MANUAL_ELASTICITY_NOT_ALLOWED_ERROR(msg);
  }
  List<NodeGroupRead> nodeGroups=cluster.getNodeGroups();
  String hadoopJobTrackerIP="String_Node_Str";
  for (  NodeGroupRead nodeGroup : nodeGroups) {
    if (nodeGroup.getRoles() != null && (nodeGroup.getRoles().contains(HadoopRole.HADOOP_JOBTRACKER_ROLE.toString()) || nodeGroup.getRoles().contains(HadoopRole.MAPR_JOBTRACKER_ROLE.toString()))) {
      if (!cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
        AuAssert.check(nodeGroup.getInstanceNum() == 1,"String_Node_Str");
      }
      hadoopJobTrackerIP=nodeGroup.getInstances().get(0).getIp();
      if (nodeGroup.getInstanceNum() > 1) {
        hadoopJobTrackerIP=getActiveJobTrackerIp(hadoopJobTrackerIP,clusterName);
      }
      AuAssert.check(!CommonUtil.isBlank(hadoopJobTrackerIP),"String_Node_Str");
      break;
    }
  }
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(clusterName));
  if (activeComputeNodeNum == null) {
    activeComputeNodeNum=cluster.getVhmTargetNum();
  }
  if (activeComputeNodeNum == -1) {
    param.put(JobConstants.VHM_ACTION_JOB_PARAM,new JobParameter(LimitInstruction.actionUnlimit));
  }
 else {
    param.put(JobConstants.VHM_ACTION_JOB_PARAM,new JobParameter(LimitInstruction.actionSetTarget));
  }
  param.put(JobConstants.ACTIVE_COMPUTE_NODE_NUMBER_JOB_PARAM,new JobParameter(Long.valueOf(activeComputeNodeNum)));
  param.put(JobConstants.CLUSTER_SUCCESS_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  JobParameters jobParameters=new JobParameters(param);
  try {
    clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.VHM_RUNNING);
    return jobManager.runJob(JobConstants.SET_MANUAL_ELASTICITY_JOB_NAME,jobParameters);
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + clusterName,e);
    clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.RUNNING);
    throw e;
  }
}

Fixed version (ground truth):
/** 
 * set cluster parameters asynchronously
 * @param clusterName
 * @param enableManualElasticity
 * @param activeComputeNodeNum
 * @return
 * @throws Exception
 */
public Long asyncSetParam(String clusterName,Integer activeComputeNodeNum,Integer minComputeNodeNum,Boolean enableAuto,Priority ioPriority) throws Exception {
  syncSetParam(clusterName,activeComputeNodeNum,minComputeNodeNum,enableAuto,ioPriority);
  ClusterRead cluster=getClusterByName(clusterName,false);
  if (!ClusterStatus.RUNNING.equals(cluster.getStatus())) {
    String msg="String_Node_Str";
    logger.error(msg);
    throw ClusterManagerException.SET_MANUAL_ELASTICITY_NOT_ALLOWED_ERROR(msg);
  }
  List<NodeGroupRead> nodeGroups=cluster.getNodeGroups();
  String hadoopJobTrackerIP="String_Node_Str";
  for (  NodeGroupRead nodeGroup : nodeGroups) {
    if (nodeGroup.getRoles() != null && (nodeGroup.getRoles().contains(HadoopRole.HADOOP_JOBTRACKER_ROLE.toString()) || nodeGroup.getRoles().contains(HadoopRole.MAPR_JOBTRACKER_ROLE.toString()))) {
      if (!cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
        AuAssert.check(nodeGroup.getInstanceNum() == 1,"String_Node_Str");
      }
      hadoopJobTrackerIP=nodeGroup.getInstances().get(0).getIp();
      if (nodeGroup.getInstanceNum() > 1) {
        hadoopJobTrackerIP=getActiveJobTrackerIp(hadoopJobTrackerIP,clusterName);
      }
      AuAssert.check(!CommonUtil.isBlank(hadoopJobTrackerIP),"String_Node_Str");
      break;
    }
  }
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(clusterName));
  if (activeComputeNodeNum == null) {
    activeComputeNodeNum=cluster.getVhmTargetNum();
  }
  if (activeComputeNodeNum == -1) {
    param.put(JobConstants.VHM_ACTION_JOB_PARAM,new JobParameter(LimitInstruction.actionUnlimit));
  }
 else {
    param.put(JobConstants.VHM_ACTION_JOB_PARAM,new JobParameter(LimitInstruction.actionSetTarget));
  }
  param.put(JobConstants.ACTIVE_COMPUTE_NODE_NUMBER_JOB_PARAM,new JobParameter(Long.valueOf(activeComputeNodeNum)));
  param.put(JobConstants.CLUSTER_SUCCESS_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.RUNNING.name()));
  JobParameters jobParameters=new JobParameters(param);
  try {
    clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.VHM_RUNNING);
    return jobManager.runJob(JobConstants.SET_MANUAL_ELASTICITY_JOB_NAME,jobParameters);
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + clusterName,e);
    clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.RUNNING);
    throw e;
  }
}