Program: 124875
Project: 124875
Buggy source:
public static void setConnectionParameters(HadoopClusterConnectionItem connectionItem,String distribution,String version,IRetrieveConfsService confsService) throws Exception {
  HadoopClusterConnection connection=(HadoopClusterConnection)connectionItem.getConnection();
  connection.setUseCustomConfs(true);
  EHadoopDistributions dist=EHadoopDistributions.getDistributionByDisplayName(distribution);
  EHadoopVersion4Drivers ver=EHadoopVersion4Drivers.indexOfByVersionDisplay(version);
  boolean supportYARN=ver.isSupportYARN();
  connection.setDistribution(dist.getName());
  connection.setDfVersion(ver.getVersionValue());
  String namenodeURI=null;
  String ns=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.DFS_NAMESERVICES.getName());
  if (StringUtils.isNotEmpty(ns)) {
    namenodeURI="String_Node_Str" + ns;
  }
 else {
    namenodeURI=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.FS_DEFAULT_URI_NEW.getName());
    if (StringUtils.isEmpty(namenodeURI)) {
      namenodeURI=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.FS_DEFAULT_URI.getName());
    }
  }
  if (namenodeURI != null) {
    connection.setNameNodeURI(namenodeURI);
  }
  String rmOrJt=null;
  if (supportYARN) {
    String useRmHa=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.YARN_RESOURCEMANAGER_HA_ENABLED.getName());
    boolean isUseRmHa=Boolean.valueOf(useRmHa);
    if (isUseRmHa) {
      String rmIds=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.YARN_RESOURCEMANAGER_HA_RM_IDS.getName());
      if (rmIds != null) {
        String[] rmIdsArray=rmIds.split("String_Node_Str");
        if (rmIdsArray.length > 0) {
          String rmId=rmIdsArray[0];
          String adminRmIdKey=String.format(EHadoopConfProperties.YARN_RESOURCEMANAGER_ADMIN_ADDRESS_RM_ID.getName(),rmId);
          rmOrJt=confsService.getConfValue(EHadoopConfs.YARN.getName(),adminRmIdKey);
        }
      }
    }
 else {
      rmOrJt=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RESOURCE_MANAGER.getName());
    }
  }
 else {
    rmOrJt=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JOB_TRACKER_URI.getName());
  }
  if (rmOrJt != null) {
    connection.setJobTrackerURI(rmOrJt);
  }
  String rms=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RESOURCEMANAGER_SCHEDULER.getName());
  if (StringUtils.isNotEmpty(rms)) {
    connection.setRmScheduler(rms);
  }
  String jh=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JOBHISTORY.getName());
  if (StringUtils.isNotEmpty(jh)) {
    connection.setJobHistory(jh);
  }
  String sd=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.STAGING_DIR.getName());
  if (StringUtils.isNotEmpty(sd)) {
    connection.setStagingDirectory(sd);
  }
  String at=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.AUTHENTICATION.getName());
  if (StringUtils.isNotEmpty(at)) {
    connection.setEnableKerberos("String_Node_Str".equals(at));
  }
  String nnp=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.KERBEROS_PRINCIPAL.getName());
  if (StringUtils.isNotEmpty(nnp)) {
    connection.setPrincipal(nnp);
  }
  String rmOrJtPrincipal=null;
  if (supportYARN) {
    rmOrJtPrincipal=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RM_PRINCIPAL.getName());
  }
 else {
    rmOrJtPrincipal=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JT_PRINCIPAL.getName());
  }
  if (rmOrJtPrincipal != null) {
    connection.setJtOrRmPrincipal(rmOrJtPrincipal);
  }
  String jhp=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JH_PRINCIPAL.getName());
  if (StringUtils.isNotEmpty(jhp)) {
    connection.setJobHistoryPrincipal(jhp);
  }
}

Fixed version (ground truth):
public static void setConnectionParameters(HadoopClusterConnectionItem connectionItem,String distribution,String version,IRetrieveConfsService confsService) throws Exception {
  HadoopClusterConnection connection=(HadoopClusterConnection)connectionItem.getConnection();
  connection.setUseCustomConfs(true);
  EHadoopDistributions dist=EHadoopDistributions.getDistributionByDisplayName(distribution);
  EHadoopVersion4Drivers ver=EHadoopVersion4Drivers.indexOfByVersionDisplay(version);
  boolean supportYARN=ver.isSupportYARN();
  connection.setDistribution(dist.getName());
  connection.setDfVersion(ver.getVersionValue());
  String namenodeURI=null;
  String ns=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.DFS_NAMESERVICES.getName());
  if (StringUtils.isNotEmpty(ns)) {
    namenodeURI="String_Node_Str" + ns;
  }
 else {
    namenodeURI=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.FS_DEFAULT_URI_NEW.getName());
    if (StringUtils.isEmpty(namenodeURI)) {
      namenodeURI=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.FS_DEFAULT_URI.getName());
    }
  }
  if (namenodeURI != null) {
    connection.setNameNodeURI(namenodeURI);
  }
  String rmOrJt=null;
  if (supportYARN) {
    String useRmHa=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.YARN_RESOURCEMANAGER_HA_ENABLED.getName());
    boolean isUseRmHa=Boolean.valueOf(useRmHa);
    if (isUseRmHa) {
      String rmIds=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.YARN_RESOURCEMANAGER_HA_RM_IDS.getName());
      if (rmIds != null) {
        String[] rmIdsArray=rmIds.split("String_Node_Str");
        if (rmIdsArray.length > 0) {
          String rmId=rmIdsArray[0];
          String adminRmIdKey=String.format(EHadoopConfProperties.YARN_RESOURCEMANAGER_ADMIN_ADDRESS_RM_ID.getName(),rmId);
          rmOrJt=confsService.getConfValue(EHadoopConfs.YARN.getName(),adminRmIdKey);
        }
      }
    }
 else {
      rmOrJt=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RESOURCE_MANAGER.getName());
    }
  }
 else {
    rmOrJt=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JOB_TRACKER_URI.getName());
  }
  if (rmOrJt != null) {
    connection.setJobTrackerURI(rmOrJt);
  }
  String rms=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RESOURCEMANAGER_SCHEDULER.getName());
  if (StringUtils.isNotEmpty(rms)) {
    connection.setRmScheduler(rms);
  }
  String jh=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JOBHISTORY.getName());
  if (StringUtils.isEmpty(jh)) {
    jh=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.JOBHISTORY.getName());
  }
  if (StringUtils.isNotEmpty(jh)) {
    connection.setJobHistory(jh);
  }
  String sd=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.STAGING_DIR.getName());
  if (StringUtils.isEmpty(sd)) {
    sd=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.STAGING_DIR.getName());
  }
  if (StringUtils.isNotEmpty(sd)) {
    connection.setStagingDirectory(sd);
  }
  String at=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.AUTHENTICATION.getName());
  if (StringUtils.isNotEmpty(at)) {
    connection.setEnableKerberos("String_Node_Str".equals(at));
  }
  String nnp=confsService.getConfValue(EHadoopConfs.HDFS.getName(),EHadoopConfProperties.KERBEROS_PRINCIPAL.getName());
  if (StringUtils.isNotEmpty(nnp)) {
    connection.setPrincipal(nnp);
  }
  String rmOrJtPrincipal=null;
  if (supportYARN) {
    rmOrJtPrincipal=confsService.getConfValue(EHadoopConfs.YARN.getName(),EHadoopConfProperties.RM_PRINCIPAL.getName());
  }
 else {
    rmOrJtPrincipal=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JT_PRINCIPAL.getName());
  }
  if (rmOrJtPrincipal != null) {
    connection.setJtOrRmPrincipal(rmOrJtPrincipal);
  }
  String jhp=confsService.getConfValue(EHadoopConfs.MAPREDUCE2.getName(),EHadoopConfProperties.JH_PRINCIPAL.getName());
  if (StringUtils.isNotEmpty(jhp)) {
    connection.setJobHistoryPrincipal(jhp);
  }
}