Program: 126339
Project: 126339
Buggy source:
/** 
 * ggu Comment method "cloneOriginalValueConnection". only clone the properties of connection.
 * @param selectedContext
 */
public static DatabaseConnection cloneOriginalValueConnection(DatabaseConnection dbConn,boolean defaultContext,String selectedContext){
  if (dbConn == null) {
    return null;
  }
  ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(null,dbConn,selectedContext,defaultContext);
  DatabaseConnection cloneConn=ConnectionFactory.eINSTANCE.createDatabaseConnection();
  String server=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getServerName());
  String username=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getUsername());
  String password=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getRawPassword());
  String port=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getPort());
  String sidOrDatabase=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getSID());
  String datasource=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDatasourceName());
  String filePath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getFileFieldName());
  String schemaOracle=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getUiSchema());
  String dbRootPath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDBRootPath());
  String additionParam=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getAdditionalParams());
  String url=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getURL());
  String className=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDriverClass());
  String jarPath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDriverJarPath());
  String dbmsID=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  cloneConn.setAdditionalParams(additionParam);
  cloneConn.setDatasourceName(datasource);
  cloneConn.setDBRootPath(dbRootPath);
  cloneConn.setFileFieldName(filePath);
  cloneConn.setRawPassword(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 (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
    String template=null;
    if (dbConn.getURL() != null && dbConn.getURL().startsWith(DbConnStrForHive.URL_HIVE_2_TEMPLATE)) {
      template=DbConnStrForHive.URL_HIVE_2_TEMPLATE;
    }
 else {
      template=DbConnStrForHive.URL_HIVE_1_TEMPLATE;
    }
    String newURl=DatabaseConnStrUtil.getHiveURLString(dbConn,server,port,sidOrDatabase,template);
    cloneConn.setURL(newURl);
    return cloneConn;
  }
  if (EDatabaseTypeName.IBMDB2.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
    String cursorForDb2="String_Node_Str";
    String database=sidOrDatabase + cursorForDb2;
    String newURL=DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(),dbConn.getDbVersionString(),server,username,password,port,database,filePath.toLowerCase(),datasource,dbRootPath,additionParam);
    cloneConn.setURL(newURL);
    return cloneConn;
  }
  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):
/** 
 * ggu Comment method "cloneOriginalValueConnection". only clone the properties of connection.
 * @param selectedContext
 */
public static DatabaseConnection cloneOriginalValueConnection(DatabaseConnection dbConn,boolean defaultContext,String selectedContext){
  if (dbConn == null) {
    return null;
  }
  ContextType contextType=ConnectionContextHelper.getContextTypeForContextMode(null,dbConn,selectedContext,defaultContext);
  DatabaseConnection cloneConn=ConnectionFactory.eINSTANCE.createDatabaseConnection();
  String server=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getServerName());
  String username=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getUsername());
  String password=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getRawPassword());
  String port=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getPort());
  String sidOrDatabase=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getSID());
  String datasource=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDatasourceName());
  String filePath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getFileFieldName());
  String schemaOracle=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getUiSchema());
  String dbRootPath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDBRootPath());
  String additionParam=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getAdditionalParams());
  String url=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getURL());
  String className=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDriverClass());
  String jarPath=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDriverJarPath());
  String dbmsID=ConnectionContextHelper.getOriginalValue(contextType,dbConn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  cloneConn.setAdditionalParams(additionParam);
  cloneConn.setDatasourceName(datasource);
  cloneConn.setDBRootPath(dbRootPath);
  cloneConn.setFileFieldName(filePath);
  cloneConn.setRawPassword(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 (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
    String template=null;
    String hiveServerVersion=HiveServerVersionInfo.HIVE_SERVER_1.getKey();
    EMap<String,String> parameterMap=dbConn.getParameters();
    if (parameterMap != null) {
      hiveServerVersion=parameterMap.get(ConnParameterKeys.HIVE_SERVER_VERSION);
    }
    if (HiveServerVersionInfo.HIVE_SERVER_2.getKey().equals(hiveServerVersion)) {
      template=DbConnStrForHive.URL_HIVE_2_TEMPLATE;
    }
 else {
      template=DbConnStrForHive.URL_HIVE_1_TEMPLATE;
    }
    String newURl=DatabaseConnStrUtil.getHiveURLString(dbConn,server,port,sidOrDatabase,template);
    cloneConn.setURL(newURl);
    return cloneConn;
  }
  if (EDatabaseTypeName.IBMDB2.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
    String cursorForDb2="String_Node_Str";
    String database=sidOrDatabase + cursorForDb2;
    String newURL=DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(),dbConn.getDbVersionString(),server,username,password,port,database,filePath.toLowerCase(),datasource,dbRootPath,additionParam);
    cloneConn.setURL(newURL);
    return cloneConn;
  }
  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;
}