Program: 127406
Project: 127406
Buggy source:
/** 
 * DOC sizhaoliu Comment method "cloneOriginalValueConnection".
 * @param dbConn
 * @param contextProperties
 * @return
 */
public static DatabaseConnection cloneOriginalValueConnection(DatabaseConnection dbConn,Properties contextProperties){
  if (dbConn == null) {
    return null;
  }
  ContextType contextType=null;
  DatabaseConnection cloneConn=ConnectionFactory.eINSTANCE.createDatabaseConnection();
  String server=getOriginalValue(contextProperties,dbConn.getServerName());
  String username=getOriginalValue(contextProperties,dbConn.getUsername());
  String password=getOriginalValue(contextProperties,dbConn.getRawPassword());
  String port=getOriginalValue(contextProperties,dbConn.getPort());
  String sidOrDatabase=getOriginalValue(contextProperties,dbConn.getSID());
  String datasource=getOriginalValue(contextProperties,dbConn.getDatasourceName());
  String filePath=getOriginalValue(contextProperties,dbConn.getFileFieldName());
  String schemaOracle=getOriginalValue(contextProperties,dbConn.getUiSchema());
  String dbRootPath=getOriginalValue(contextProperties,dbConn.getDBRootPath());
  String additionParam=getOriginalValue(contextProperties,dbConn.getAdditionalParams());
  String url=getOriginalValue(contextProperties,dbConn.getURL());
  String className=getOriginalValue(contextProperties,dbConn.getDriverClass());
  String jarPath=getOriginalValue(contextProperties,dbConn.getDriverJarPath());
  String dbmsID=getOriginalValue(contextProperties,dbConn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  cloneConn.setAdditionalParams(additionParam);
  cloneConn.setDatasourceName(datasource);
  cloneConn.setDBRootPath(dbRootPath);
  cloneConn.setFileFieldName(filePath);
  if (contextType != null) {
    String encryptedPassword=null;
    try {
      encryptedPassword=PasswordEncryptUtil.encryptPassword(password);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
    }
    cloneConn.setPassword(encryptedPassword);
  }
 else {
    cloneConn.setPassword(password);
  }
  cloneConn.setPort(port);
  cloneConn.setUiSchema(schemaOracle);
  cloneConn.setServerName(server);
  cloneConn.setSID(sidOrDatabase);
  cloneConn.setUsername(username);
  cloneConn.setDriverJarPath(jarPath);
  cloneConn.setComment(dbConn.getComment());
  cloneConn.setDatabaseType(dbConn.getDatabaseType());
  cloneConn.setDbmsId(dbmsID);
  cloneConn.setDivergency(dbConn.isDivergency());
  cloneConn.setDbVersionString(dbConn.getDbVersionString());
  cloneConn.setId(dbConn.getId());
  cloneConn.setLabel(dbConn.getLabel());
  cloneConn.setNullChar(dbConn.getNullChar());
  cloneConn.setProductId(dbConn.getProductId());
  cloneConn.setSqlSynthax(dbConn.getSqlSynthax());
  cloneConn.setStandardSQL(dbConn.isStandardSQL());
  cloneConn.setStringQuote(dbConn.getStringQuote());
  cloneConn.setSynchronised(dbConn.isSynchronised());
  cloneConn.setSystemSQL(dbConn.isSystemSQL());
  cloneConn.setVersion(dbConn.getVersion());
  cloneConn.setReadOnly(dbConn.isReadOnly());
  cloneConn.setDriverClass(className);
  cloneConn.setName(dbConn.getName());
  cloneOtherParameters(dbConn,cloneConn);
  if (dbConn.isSetSQLMode()) {
    cloneConn.setSQLMode(dbConn.isSQLMode());
  }
 else {
    cloneConn.setSQLMode(true);
  }
  if (contextType != null && !EDatabaseTypeName.GENERAL_JDBC.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
    String newURL=DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(),dbConn.getDbVersionString(),server,username,password,port,sidOrDatabase,filePath.toLowerCase(),datasource,dbRootPath,additionParam);
    cloneConn.setURL(newURL);
    return cloneConn;
  }
  if (dbConn.getURL() != null && !dbConn.getURL().equals("String_Node_Str")) {
    cloneConn.setURL(url);
  }
 else {
    String newURL=DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(),dbConn.getDbVersionString(),server,username,password,port,sidOrDatabase,filePath.toLowerCase(),datasource,dbRootPath,additionParam);
    cloneConn.setURL(newURL);
  }
  return cloneConn;
}

Fixed version (ground truth):
public static FileConnection cloneOriginalValueConnection(FileConnection fileConn,Properties contextProperties){
  if (fileConn == null) {
    return null;
  }
  FileConnection cloneConn=null;
  if (fileConn instanceof DelimitedFileConnection) {
    cloneConn=ConnectionFactory.eINSTANCE.createDelimitedFileConnection();
  }
 else   if (fileConn instanceof PositionalFileConnection) {
    cloneConn=ConnectionFactory.eINSTANCE.createPositionalFileConnection();
  }
 else   if (fileConn instanceof RegexpFileConnection) {
    cloneConn=ConnectionFactory.eINSTANCE.createRegexpFileConnection();
  }
 else   if (fileConn instanceof FileExcelConnection) {
    cloneConn=ConnectionFactory.eINSTANCE.createFileExcelConnection();
  }
 else   if (fileConn instanceof HL7Connection) {
    cloneConn=ConnectionFactory.eINSTANCE.createHL7Connection();
  }
 else   if (fileConn instanceof EbcdicConnection) {
    cloneConn=ConnectionFactory.eINSTANCE.createEbcdicConnection();
  }
  if (cloneConn != null) {
    String filePath=getOriginalValue(contextProperties,fileConn.getFilePath());
    String encoding=getOriginalValue(contextProperties,fileConn.getEncoding());
    String headValue=getOriginalValue(contextProperties,fileConn.getHeaderValue());
    String footerValue=getOriginalValue(contextProperties,fileConn.getFooterValue());
    String limitValue=getOriginalValue(contextProperties,fileConn.getLimitValue());
    filePath=TalendQuoteUtils.removeQuotes(filePath);
    encoding=TalendQuoteUtils.removeQuotes(encoding);
    cloneConn.setFilePath(filePath);
    cloneConn.setEncoding(encoding);
    cloneConn.setHeaderValue(headValue);
    cloneConn.setFooterValue(footerValue);
    cloneConn.setLimitValue(limitValue);
    if (fileConn instanceof DelimitedFileConnection || fileConn instanceof PositionalFileConnection || fileConn instanceof RegexpFileConnection) {
      String fieldSeparatorValue=getOriginalValue(contextProperties,fileConn.getFieldSeparatorValue());
      String rowSeparatorValue=getOriginalValue(contextProperties,fileConn.getRowSeparatorValue());
      cloneConn.setFieldSeparatorValue(fieldSeparatorValue);
      cloneConn.setRowSeparatorValue(rowSeparatorValue);
      if (fileConn instanceof DelimitedFileConnection) {
        ((DelimitedFileConnection)cloneConn).setFieldSeparatorType(((DelimitedFileConnection)fileConn).getFieldSeparatorType());
      }
    }
    if (fileConn instanceof FileExcelConnection) {
      FileExcelConnection excelConnection=(FileExcelConnection)fileConn;
      FileExcelConnection cloneExcelConnection=(FileExcelConnection)cloneConn;
      String thousandSeparator=getOriginalValue(contextProperties,excelConnection.getThousandSeparator());
      String decimalSeparator=getOriginalValue(contextProperties,excelConnection.getDecimalSeparator());
      String firstColumn=getOriginalValue(contextProperties,excelConnection.getFirstColumn());
      String lastColumn=getOriginalValue(contextProperties,excelConnection.getLastColumn());
      cloneExcelConnection.setThousandSeparator(thousandSeparator);
      cloneExcelConnection.setDecimalSeparator(decimalSeparator);
      cloneExcelConnection.setFirstColumn(firstColumn);
      cloneExcelConnection.setLastColumn(lastColumn);
      cloneExcelConnection.setSelectAllSheets(excelConnection.isSelectAllSheets());
      cloneExcelConnection.setSheetName(excelConnection.getSheetName());
      ArrayList sheetList=excelConnection.getSheetList();
      cloneExcelConnection.setSheetList((ArrayList)sheetList.clone());
      EList sheetColumns=excelConnection.getSheetColumns();
      if (sheetColumns != null && sheetColumns instanceof BasicEList) {
        cloneExcelConnection.getSheetColumns().addAll((EList)((BasicEList)sheetColumns).clone());
      }
      cloneExcelConnection.setAdvancedSpearator(excelConnection.isAdvancedSpearator());
      cloneConn.setFieldSeparatorValue(fileConn.getFieldSeparatorValue());
      cloneConn.setRowSeparatorType(fileConn.getRowSeparatorType());
      cloneConn.setRowSeparatorValue(fileConn.getRowSeparatorValue());
    }
    cloneConn.setRowSeparatorType(fileConn.getRowSeparatorType());
    cloneConn.setCsvOption(fileConn.isCsvOption());
    cloneConn.setEscapeChar(fileConn.getEscapeChar());
    cloneConn.setEscapeType(fileConn.getEscapeType());
    cloneConn.setFirstLineCaption(fileConn.isFirstLineCaption());
    cloneConn.setFormat(fileConn.getFormat());
    cloneConn.setRemoveEmptyRow(fileConn.isRemoveEmptyRow());
    cloneConn.setServer(fileConn.getServer());
    cloneConn.setTextEnclosure(fileConn.getTextEnclosure());
    cloneConn.setTextIdentifier(fileConn.getTextIdentifier());
    cloneConn.setUseFooter(fileConn.isUseFooter());
    cloneConn.setUseHeader(fileConn.isUseHeader());
    cloneConn.setUseLimit(fileConn.isUseLimit());
    CloneConnectionUtils.cloneConnectionProperties(fileConn,cloneConn);
  }
  return cloneConn;
}