Program: 48537
Project: 48537
Buggy source:
/** 
 * set cluster parameters synchronously
 * @param clusterName
 * @param activeComputeNodeNum
 * @param minComputeNodeNum
 * @param maxComputeNodeNum
 * @param enableAuto
 * @param ioPriority
 * @return
 * @throws Exception
 */
@SuppressWarnings("String_Node_Str") public List<String> syncSetParam(String clusterName,Integer activeComputeNodeNum,Integer minComputeNodeNum,Integer maxComputeNodeNum,Boolean enableAuto,Priority ioPriority) throws Exception {
  ClusterEntity cluster=clusterEntityMgr.findByName(clusterName);
  ClusterRead clusterRead=getClusterByName(clusterName,false);
  if (cluster == null) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw BddException.NOT_FOUND("String_Node_Str",clusterName);
  }
  ValidationUtils.validateVersion(clusterEntityMgr,clusterName);
  clusterEntityMgr.cleanupActionError(clusterName);
  if (ioPriority != null) {
    prioritizeCluster(clusterName,ioPriority);
  }
  cluster=clusterEntityMgr.findByName(clusterName);
  if (enableAuto != null && enableAuto != cluster.getAutomationEnable()) {
    if (enableAuto && cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
      logger.error("String_Node_Str" + clusterName + "String_Node_Str");
      throw BddException.NOT_ALLOWED_SCALING("String_Node_Str",clusterName);
    }
    cluster.setAutomationEnable(enableAuto);
  }
  if (minComputeNodeNum != null && minComputeNodeNum != cluster.getVhmMinNum()) {
    cluster.setVhmMinNum(minComputeNodeNum);
  }
  if (maxComputeNodeNum != null && maxComputeNodeNum != cluster.getVhmMaxNum()) {
    cluster.setVhmMaxNum(maxComputeNodeNum);
  }
  List<String> nodeGroupNames=new ArrayList<String>();
  if ((enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null || activeComputeNodeNum != null) && !clusterRead.validateSetManualElasticity(nodeGroupNames)) {
    throw BddException.INVALID_PARAMETER("String_Node_Str",clusterName);
  }
  if (activeComputeNodeNum != null) {
    if (!activeComputeNodeNum.equals(cluster.getVhmTargetNum())) {
      cluster.setVhmTargetNum(activeComputeNodeNum);
    }
  }
  if ((enableAuto != null) && !cluster.getStatus().isActiveServiceStatus()) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  if (!cluster.getStatus().isActiveServiceStatus() && !ClusterStatus.SERVICE_ERROR.equals(cluster.getStatus()) && !ClusterStatus.STOPPED.equals(cluster.getStatus())) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  clusterEntityMgr.update(cluster);
  if (enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null) {
    boolean success=clusteringService.setAutoElasticity(clusterName,false);
    if (!success) {
      throw ClusterManagerException.FAILED_TO_SET_AUTO_ELASTICITY_ERROR(clusterName,"String_Node_Str");
    }
  }
  if (enableAuto != null && !enableAuto && cluster.getVhmTargetNum() == null) {
    JobUtils.waitForManual(clusterName,executionService);
  }
  return nodeGroupNames;
}

Fixed version (ground truth):
/** 
 * set cluster parameters synchronously
 * @param clusterName
 * @param activeComputeNodeNum
 * @param minComputeNodeNum
 * @param maxComputeNodeNum
 * @param enableAuto
 * @param ioPriority
 * @return
 * @throws Exception
 */
@SuppressWarnings("String_Node_Str") public List<String> syncSetParam(String clusterName,Integer activeComputeNodeNum,Integer minComputeNodeNum,Integer maxComputeNodeNum,Boolean enableAuto,Priority ioPriority) throws Exception {
  ClusterEntity cluster=clusterEntityMgr.findByName(clusterName);
  ClusterRead clusterRead=getClusterByName(clusterName,false);
  if (cluster == null) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw BddException.NOT_FOUND("String_Node_Str",clusterName);
  }
  ValidationUtils.validateVersion(clusterEntityMgr,clusterName);
  clusterEntityMgr.cleanupActionError(clusterName);
  if (ioPriority != null) {
    prioritizeCluster(clusterName,ioPriority);
  }
  cluster=clusterEntityMgr.findByName(clusterName);
  if (enableAuto != null && enableAuto != cluster.getAutomationEnable()) {
    if (enableAuto && cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) {
      logger.error("String_Node_Str" + clusterName + "String_Node_Str");
      throw BddException.NOT_ALLOWED_SCALING("String_Node_Str",clusterName);
    }
    cluster.setAutomationEnable(enableAuto);
  }
  if (minComputeNodeNum != null && minComputeNodeNum != cluster.getVhmMinNum()) {
    cluster.setVhmMinNum(minComputeNodeNum);
  }
  if (maxComputeNodeNum != null && maxComputeNodeNum != cluster.getVhmMaxNum()) {
    cluster.setVhmMaxNum(maxComputeNodeNum);
  }
  List<String> nodeGroupNames=new ArrayList<String>();
  if ((enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null || activeComputeNodeNum != null) && !clusterRead.validateSetManualElasticity(nodeGroupNames)) {
    throw BddException.INVALID_PARAMETER("String_Node_Str",clusterName);
  }
  if (activeComputeNodeNum != null) {
    if (!activeComputeNodeNum.equals(cluster.getVhmTargetNum())) {
      cluster.setVhmTargetNum(activeComputeNodeNum);
    }
  }
  if ((enableAuto != null) && !cluster.getStatus().isActiveServiceStatus()) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  if (!cluster.getStatus().isActiveServiceStatus() && !ClusterStatus.SERVICE_STOPPED.equals(cluster.getStatus()) && !ClusterStatus.STOPPED.equals(cluster.getStatus())) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  clusterEntityMgr.update(cluster);
  if (enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null) {
    boolean success=clusteringService.setAutoElasticity(clusterName,false);
    if (!success) {
      throw ClusterManagerException.FAILED_TO_SET_AUTO_ELASTICITY_ERROR(clusterName,"String_Node_Str");
    }
  }
  if (enableAuto != null && !enableAuto && cluster.getVhmTargetNum() == null) {
    JobUtils.waitForManual(clusterName,executionService);
  }
  return nodeGroupNames;
}