Program: 127924
Project: 127924
Buggy source:
static void revertPropertiesForContextMode(DatabaseConnection conn,ContextType contextType){
  if (conn == null || contextType == null) {
    return;
  }
  String server=ConnectionContextHelper.getOriginalValue(contextType,conn.getServerName());
  String username=ConnectionContextHelper.getOriginalValue(contextType,conn.getUsername());
  String password=ConnectionContextHelper.getOriginalValue(contextType,conn.getPassword());
  String port=ConnectionContextHelper.getOriginalValue(contextType,conn.getPort());
  String sidOrDatabase=ConnectionContextHelper.getOriginalValue(contextType,conn.getSID());
  String datasource=ConnectionContextHelper.getOriginalValue(contextType,conn.getDatasourceName());
  String filePath=ConnectionContextHelper.getOriginalValue(contextType,conn.getFileFieldName());
  String schemaOracle=ConnectionContextHelper.getOriginalValue(contextType,conn.getUiSchema());
  String dbRootPath=ConnectionContextHelper.getOriginalValue(contextType,conn.getDBRootPath());
  String additionParam=ConnectionContextHelper.getOriginalValue(contextType,conn.getAdditionalParams());
  String jdbcUrl=ConnectionContextHelper.getOriginalValue(contextType,conn.getURL());
  String driverJar=ConnectionContextHelper.getOriginalValue(contextType,conn.getDriverJarPath());
  String className=ConnectionContextHelper.getOriginalValue(contextType,conn.getDriverClass());
  String mappingFile=ConnectionContextHelper.getOriginalValue(contextType,conn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  conn.setAdditionalParams(additionParam);
  conn.setDatasourceName(datasource);
  conn.setDBRootPath(dbRootPath);
  conn.setFileFieldName(filePath);
  try {
    conn.setPassword(PasswordEncryptUtil.encryptPassword(password));
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  conn.setPort(port);
  conn.setUiSchema(schemaOracle);
  conn.setServerName(server);
  if (conn.getDataPackage() != null) {
    for (    orgomg.cwm.objectmodel.core.Package dataPackage : conn.getDataPackage()) {
      if (dataPackage instanceof ModelElement) {
        ModelElement element=dataPackage;
        if (conn.getSID() != null && conn.getSID().equals(element.getName())) {
          element.setName(sidOrDatabase);
        }
      }
    }
  }
  conn.setSID(sidOrDatabase);
  conn.setUsername(username);
  conn.setURL(jdbcUrl);
  conn.setDriverJarPath(driverJar);
  conn.setDriverClass(className);
  conn.setDbmsId(mappingFile);
  revertConnSubElement(conn,contextType);
}

Fixed version (ground truth):
static void revertPropertiesForContextMode(DatabaseConnection conn,ContextType contextType){
  if (conn == null || contextType == null) {
    return;
  }
  String server=ConnectionContextHelper.getOriginalValue(contextType,conn.getServerName());
  String username=ConnectionContextHelper.getOriginalValue(contextType,conn.getUsername());
  String password=ConnectionContextHelper.getOriginalValue(contextType,conn.getPassword());
  String port=ConnectionContextHelper.getOriginalValue(contextType,conn.getPort());
  String sidOrDatabase=ConnectionContextHelper.getOriginalValue(contextType,conn.getSID());
  String datasource=ConnectionContextHelper.getOriginalValue(contextType,conn.getDatasourceName());
  String filePath=ConnectionContextHelper.getOriginalValue(contextType,conn.getFileFieldName());
  String schemaOracle=ConnectionContextHelper.getOriginalValue(contextType,conn.getUiSchema());
  String dbRootPath=ConnectionContextHelper.getOriginalValue(contextType,conn.getDBRootPath());
  String additionParam=ConnectionContextHelper.getOriginalValue(contextType,conn.getAdditionalParams());
  String jdbcUrl=ConnectionContextHelper.getOriginalValue(contextType,conn.getURL());
  String driverJar=ConnectionContextHelper.getOriginalValue(contextType,conn.getDriverJarPath());
  String className=ConnectionContextHelper.getOriginalValue(contextType,conn.getDriverClass());
  String mappingFile=ConnectionContextHelper.getOriginalValue(contextType,conn.getDbmsId());
  filePath=TalendQuoteUtils.removeQuotes(filePath);
  dbRootPath=TalendQuoteUtils.removeQuotes(dbRootPath);
  conn.setAdditionalParams(additionParam);
  conn.setDatasourceName(datasource);
  conn.setDBRootPath(dbRootPath);
  conn.setFileFieldName(filePath);
  try {
    conn.setPassword(PasswordEncryptUtil.encryptPassword(password));
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  conn.setPort(port);
  conn.setUiSchema(schemaOracle);
  conn.setServerName(server);
  if (conn.getDataPackage() != null) {
    for (    orgomg.cwm.objectmodel.core.Package dataPackage : conn.getDataPackage()) {
      if (dataPackage instanceof ModelElement) {
        ModelElement element=dataPackage;
        if (conn.getSID() != null && conn.getSID().equals(element.getName())) {
          element.setName(sidOrDatabase);
        }
      }
    }
  }
  conn.setSID(sidOrDatabase);
  conn.setUsername(username);
  conn.setURL(jdbcUrl);
  conn.setDriverJarPath(driverJar);
  conn.setDriverClass(className);
  conn.setDbmsId(mappingFile);
  revertConnSubElement(conn,contextType);
  if (EDatabaseTypeName.HIVE.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
    String jobTracker=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL,ConnectionContextHelper.getOriginalValue(contextType,jobTracker));
    String nameNode=conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL);
    conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL,ConnectionContextHelper.getOriginalValue(contextType,nameNode));
  }
}