Program: 124762
Project: 124762
Buggy source:
/** 
 * DOC ycbai Comment method "getHadoopDbParameters". Get db connection(like hbase, hive) parameters by hadoop cluster.
 * @param clusterId
 * @return
 */
public static Map<String,String> getHadoopDbParameters(String clusterId){
  Map<String,String> map=new HashMap<String,String>();
  HadoopClusterConnectionItem clusterItem=HCRepositoryUtil.getRelativeHadoopClusterItem(clusterId);
  if (clusterItem != null) {
    HadoopClusterConnection hcConnection=(HadoopClusterConnection)clusterItem.getConnection();
    map.put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID,clusterItem.getProperty().getId());
    map.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getNameNodeURI()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobTrackerURI()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_YARN,String.valueOf(hcConnection.isUseYarn()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_CUSTOM_CONFS,String.valueOf(hcConnection.isUseCustomConfs()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB,String.valueOf(hcConnection.isEnableKerberos()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJtOrRmPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_HISTORY_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobHistoryPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_RESOURCEMANAGER_SCHEDULER_ADDRESS,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getRmScheduler()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOBHISTORY_ADDRESS,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobHistory()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_STAGING_DIRECTORY,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getStagingDirectory()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_DATANODE_HOSTNAME,String.valueOf(hcConnection.isUseDNHost()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_DB_SERVER,HadoopParameterUtil.getHostNameFromNameNodeURI(ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getNameNodeURI())));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USERNAME,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getUserName()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION,hcConnection.getDistribution());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION,hcConnection.getDfVersion());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_DISTRIBUTION,hcConnection.getDistribution());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_VERSION,hcConnection.getDfVersion());
    if (hcConnection.isEnableKerberos()) {
      map.put(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB,String.valueOf(hcConnection.isUseKeytab()));
      if (hcConnection.isUseKeytab()) {
        map.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getKeytabPrincipal()));
        map.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getKeytab()));
      }
    }
  }
  return map;
}

Fixed version (ground truth):
/** 
 * DOC ycbai Comment method "getHadoopDbParameters". Get db connection(like hbase, hive) parameters by hadoop cluster.
 * @param clusterId
 * @return
 */
public static Map<String,String> getHadoopDbParameters(String clusterId){
  Map<String,String> map=new HashMap<String,String>();
  HadoopClusterConnectionItem clusterItem=HCRepositoryUtil.getRelativeHadoopClusterItem(clusterId);
  if (clusterItem != null) {
    HadoopClusterConnection hcConnection=(HadoopClusterConnection)clusterItem.getConnection();
    map.put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID,clusterItem.getProperty().getId());
    map.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getNameNodeURI()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobTrackerURI()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_YARN,String.valueOf(hcConnection.isUseYarn()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_CUSTOM_CONFS,String.valueOf(hcConnection.isUseCustomConfs()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB,String.valueOf(hcConnection.isEnableKerberos()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJtOrRmPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOB_HISTORY_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobHistoryPrincipal()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_RESOURCEMANAGER_SCHEDULER_ADDRESS,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getRmScheduler()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_JOBHISTORY_ADDRESS,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getJobHistory()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_STAGING_DIRECTORY,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getStagingDirectory()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USE_DATANODE_HOSTNAME,String.valueOf(hcConnection.isUseDNHost()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_DB_SERVER,HadoopParameterUtil.getHostNameFromNameNodeURI(ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getNameNodeURI())));
    map.put(ConnParameterKeys.CONN_PARA_KEY_USERNAME,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getUserName()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION,hcConnection.getDistribution());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION,hcConnection.getDfVersion());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_DISTRIBUTION,hcConnection.getDistribution());
    map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_VERSION,hcConnection.getDfVersion());
    if (hcConnection.isEnableKerberos()) {
      map.put(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB,String.valueOf(hcConnection.isUseKeytab()));
      if (hcConnection.isUseKeytab()) {
        map.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getKeytabPrincipal()));
        map.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getKeytab()));
      }
    }
    map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USE_MAPRTICKET,String.valueOf(hcConnection.isEnableMaprT()));
    map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET,String.valueOf(hcConnection.isEnableMaprT()));
    if (hcConnection.isEnableMaprT()) {
      map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getUserName()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTPassword()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTCluster()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTDuration()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getUserName()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTPassword()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTCluster()));
      map.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION,ConnectionContextHelper.getParamValueOffContext(hcConnection,hcConnection.getMaprTDuration()));
    }
  }
  return map;
}