Program: 48671
Project: 48671
Buggy source:
public Long upgradeClusterByName(String clusterName) throws Exception {
  logger.info("String_Node_Str" + clusterName);
  ClusterEntity cluster=clusterEntityMgr.findByName(clusterName);
  if (cluster == null) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw BddException.NOT_FOUND("String_Node_Str",clusterName);
  }
  if (!clusterEntityMgr.isNeedToUpgrade(clusterName)) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw ClusterManagerException.ALREADY_LATEST_VERSION_ERROR(clusterName);
  }
  if (!ClusterStatus.RUNNING.equals(cluster.getStatus()) && !ClusterStatus.STOPPED.equals(cluster.getStatus()) && !ClusterStatus.ERROR.equals(cluster.getStatus())&& !ClusterStatus.CONFIGURE_ERROR.equals(cluster.getStatus())&& !ClusterStatus.UPGRADE_ERROR.equals(cluster.getStatus())) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.UPGRADE_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(clusterName));
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.UPGRADE_ERROR.name()));
  JobParameters jobParameters=new JobParameters(param);
  clusterEntityMgr.storeClusterLastStatus(clusterName);
  clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.UPGRADING);
  try {
    return jobManager.runJob(JobConstants.UPGRADE_CLUSTER_JOB_NAME,jobParameters);
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + clusterName,e);
    cluster=clusterEntityMgr.findByName(clusterName);
    if (cluster != null) {
      clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.UPGRADE_ERROR);
    }
    throw e;
  }
}

Fixed version (ground truth):
public Long upgradeClusterByName(String clusterName) throws Exception {
  logger.info("String_Node_Str" + clusterName);
  ClusterEntity cluster=clusterEntityMgr.findByName(clusterName);
  if (cluster == null) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw BddException.NOT_FOUND("String_Node_Str",clusterName);
  }
  if (!clusterEntityMgr.needUpgrade(clusterName)) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str");
    throw ClusterManagerException.ALREADY_LATEST_VERSION_ERROR(clusterName);
  }
  if (!ClusterStatus.RUNNING.equals(cluster.getStatus()) && !ClusterStatus.STOPPED.equals(cluster.getStatus()) && !ClusterStatus.ERROR.equals(cluster.getStatus())&& !ClusterStatus.CONFIGURE_ERROR.equals(cluster.getStatus())&& !ClusterStatus.UPGRADE_ERROR.equals(cluster.getStatus())) {
    logger.error("String_Node_Str" + clusterName + "String_Node_Str"+ cluster.getStatus()+ "String_Node_Str");
    throw ClusterManagerException.UPGRADE_NOT_ALLOWED_ERROR(clusterName,"String_Node_Str");
  }
  Map<String,JobParameter> param=new TreeMap<String,JobParameter>();
  param.put(JobConstants.CLUSTER_NAME_JOB_PARAM,new JobParameter(clusterName));
  param.put(JobConstants.TIMESTAMP_JOB_PARAM,new JobParameter(new Date()));
  param.put(JobConstants.CLUSTER_FAILURE_STATUS_JOB_PARAM,new JobParameter(ClusterStatus.UPGRADE_ERROR.name()));
  JobParameters jobParameters=new JobParameters(param);
  clusterEntityMgr.storeClusterLastStatus(clusterName);
  clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.UPGRADING);
  clusterEntityMgr.updateNodesAction(clusterName,Constants.NODE_ACTION_UPGRADING);
  clusterEntityMgr.cleanupErrorForClusterUpgrade(clusterName);
  try {
    return jobManager.runJob(JobConstants.UPGRADE_CLUSTER_JOB_NAME,jobParameters);
  }
 catch (  Exception e) {
    logger.error("String_Node_Str" + clusterName,e);
    cluster=clusterEntityMgr.findByName(clusterName);
    if (cluster != null) {
      clusterEntityMgr.updateClusterStatus(clusterName,ClusterStatus.UPGRADE_ERROR);
    }
    throw e;
  }
}