Program: 124873
Project: 124873
Buggy source:
/** 
 * DOC ycbai Comment method "convert2HDFSConnectionBean". Convert HDFSConnection to HDFSConnectionBean
 * @param connection
 * @return
 */
public static HDFSConnectionBean convert2HDFSConnectionBean(HDFSConnection connection){
  HDFSConnectionBean bean=new HDFSConnectionBean();
  try {
    HadoopClusterConnection hcConnection=HCRepositoryUtil.getRelativeHadoopClusterConnection(connection);
    if (hcConnection != null) {
      BeanUtils.copyProperties(bean,hcConnection);
      Map<String,Object> properties=bean.getAdditionalProperties();
      Map<String,Set<String>> customVersionMap=HCVersionUtil.getCustomVersionMap(hcConnection);
      Iterator<Entry<String,Set<String>>> iter=customVersionMap.entrySet().iterator();
      while (iter.hasNext()) {
        Map.Entry<String,Set<String>> entry=iter.next();
        String groupName=entry.getKey();
        Set<String> jars=entry.getValue();
        if (jars != null && jars.size() > 0) {
          properties.put(groupName,jars);
        }
      }
    }
    bean.setUserName(connection.getUserName());
    bean.setFieldSeparator(connection.getFieldSeparator());
    bean.setRowSeparator(connection.getRowSeparator());
    bean.setRelativeHadoopClusterId(connection.getRelativeHadoopClusterId());
    Map<String,Object> configurations=bean.getConfigurations();
    List<Map<String,Object>> hadoopProperties=HadoopRepositoryUtil.getHadoopPropertiesFullList(connection,connection.getHadoopProperties(),false);
    for (    Map<String,Object> propMap : hadoopProperties) {
      String key=TalendQuoteUtils.removeQuotesIfExist(String.valueOf(propMap.get("String_Node_Str")));
      String value=TalendQuoteUtils.removeQuotesIfExist(String.valueOf(propMap.get("String_Node_Str")));
      if (StringUtils.isNotEmpty(key) && value != null) {
        configurations.put(key,value);
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
  return bean;
}

Fixed version (ground truth):
/** 
 * DOC ycbai Comment method "convert2HDFSConnectionBean". Convert HDFSConnection to HDFSConnectionBean
 * @param connection
 * @return
 */
public static HDFSConnectionBean convert2HDFSConnectionBean(HDFSConnection connection){
  ContextType contextType=null;
  if (connection.isContextMode()) {
    contextType=ConnectionContextHelper.getContextTypeForContextMode(connection);
  }
  HDFSConnectionBean bean=new HDFSConnectionBean();
  bean.setContextType(contextType);
  try {
    HadoopClusterConnection hcConnection=HCRepositoryUtil.getRelativeHadoopClusterConnection(connection);
    if (hcConnection != null) {
      ContextType parentContextType=null;
      if (hcConnection.isContextMode()) {
        parentContextType=ConnectionContextHelper.getContextTypeForContextMode(hcConnection);
      }
      bean.setParentContextType(parentContextType);
      BeanUtils.copyProperties(bean,hcConnection);
      Map<String,Object> properties=bean.getAdditionalProperties();
      Map<String,Set<String>> customVersionMap=HCVersionUtil.getCustomVersionMap(hcConnection);
      Iterator<Entry<String,Set<String>>> iter=customVersionMap.entrySet().iterator();
      while (iter.hasNext()) {
        Map.Entry<String,Set<String>> entry=iter.next();
        String groupName=entry.getKey();
        Set<String> jars=entry.getValue();
        if (jars != null && jars.size() > 0) {
          properties.put(groupName,jars);
        }
      }
    }
    bean.setUserName(connection.getUserName());
    bean.setFieldSeparator(connection.getFieldSeparator());
    bean.setRowSeparator(connection.getRowSeparator());
    bean.setRelativeHadoopClusterId(connection.getRelativeHadoopClusterId());
    Map<String,Object> configurations=bean.getConfigurations();
    List<Map<String,Object>> hadoopProperties=HadoopRepositoryUtil.getHadoopPropertiesFullList(connection,connection.getHadoopProperties(),false);
    for (    Map<String,Object> propMap : hadoopProperties) {
      String key=TalendQuoteUtils.removeQuotesIfExist(String.valueOf(propMap.get("String_Node_Str")));
      String value=TalendQuoteUtils.removeQuotesIfExist(String.valueOf(propMap.get("String_Node_Str")));
      if (StringUtils.isNotEmpty(key) && value != null) {
        configurations.put(key,value);
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
  return bean;
}