Program: 120576
Project: 120576
Buggy source:
private void setAllConnectionParameters(String typ,IElement element){
  String type=null;
  if (typ != null && !typ.equals("String_Node_Str")) {
    type=typ;
  }
 else {
    type=getValueFromRepositoryName(element,"String_Node_Str");
  }
  if (type.equals("String_Node_Str") || type.contains("String_Node_Str")) {
    IElementParameter ele=element.getElementParameter("String_Node_Str");
    if (ele != null) {
      type=(String)ele.getValue();
    }
 else {
      type="String_Node_Str";
    }
  }
  if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element,"String_Node_Str").equals("String_Node_Str")) {
    type=EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
  }
  if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
    type=EDatabaseTypeName.GENERAL_JDBC.getXmlName();
  }
  if (StringUtils.trimToNull(type) != null) {
    connParameters.setDbType(type);
  }
  String frameWorkKey=getValueFromRepositoryName(element,"String_Node_Str");
  connParameters.setFrameworkType(frameWorkKey);
  String schema=getValueFromRepositoryName(element,EConnectionParameterName.SCHEMA.getName());
  connParameters.setSchema(schema);
  String userName=getValueFromRepositoryName(element,EConnectionParameterName.USERNAME.getName());
  connParameters.setUserName(userName);
  String password=getValueFromRepositoryName(element,EConnectionParameterName.PASSWORD.getName());
  connParameters.setPassword(password);
  String host=getValueFromRepositoryName(element,EConnectionParameterName.SERVER_NAME.getName());
  connParameters.setHost(host);
  String port=getValueFromRepositoryName(element,EConnectionParameterName.PORT.getName());
  connParameters.setPort(port);
  boolean https=Boolean.parseBoolean(getValueFromRepositoryName(element,EConnectionParameterName.HTTPS.getName()));
  connParameters.setHttps(https);
  boolean isOracleOCI=type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
  if (isOracleOCI) {
    String localServiceName=getValueFromRepositoryNameAndParameterName(element,EConnectionParameterName.SID.getName(),EParameterName.LOCAL_SERVICE_NAME.getName());
    connParameters.setLocalServiceName(localServiceName);
  }
  String datasource=getValueFromRepositoryName(element,EConnectionParameterName.DATASOURCE.getName());
  connParameters.setDatasource(datasource);
  String dbName=getValueFromRepositoryName(element,EConnectionParameterName.SID.getName());
  connParameters.setDbName(dbName);
  if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
    String file=getValueFromRepositoryName(element,EConnectionParameterName.FILE.getName());
    connParameters.setFilename(file);
  }
  String dir=getValueFromRepositoryName(element,EConnectionParameterName.DIRECTORY.getName());
  if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
    dir=getValueFromRepositoryName(elem,EConnectionParameterName.DBPATH.getName());
  }
  connParameters.setDirectory(dir);
  String url=getValueFromRepositoryName(element,EConnectionParameterName.URL.getName());
  if (StringUtils.isEmpty(url)) {
    if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
      url=getValueFromRepositoryName(element,"String_Node_Str" + EConnectionParameterName.URL.getName());
    }
  }
  connParameters.setUrl(TalendTextUtils.removeQuotes(url));
  String driverJar=getValueFromRepositoryName(element,EConnectionParameterName.DRIVER_JAR.getName());
  connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
  String driverClass=getValueFromRepositoryName(element,EConnectionParameterName.DRIVER_CLASS.getName());
  connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
  if (driverClass != null && !"String_Node_Str".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
    if (driverClass.startsWith("String_Node_Str") && driverClass.endsWith("String_Node_Str")) {
      driverClass=TalendTextUtils.removeQuotes(driverClass);
    }
    String dbTypeByClassName="String_Node_Str";
    if (driverJar != null && !"String_Node_Str".equals(driverJar)) {
      dbTypeByClassName=ExtractMetaDataUtils.getDbTypeByClassNameAndDriverJar(driverClass,driverJar);
    }
 else {
      dbTypeByClassName=ExtractMetaDataUtils.getDbTypeByClassName(driverClass);
    }
    if (dbTypeByClassName != null) {
      connParameters.setDbType(dbTypeByClassName);
    }
  }
  String jdbcProps=getValueFromRepositoryName(element,EConnectionParameterName.PROPERTIES_STRING.getName());
  connParameters.setJdbcProperties(jdbcProps);
  String realTableName=null;
  if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
    final Object propertyValue=elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
    IMetadataTable metadataTable=null;
    String connectionId=propertyValue.toString().split("String_Node_Str")[0];
    String tableLabel=propertyValue.toString().split("String_Node_Str")[1];
    IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
    Item item=null;
    try {
      IRepositoryViewObject repobj=factory.getLastVersion(connectionId);
      if (repobj != null) {
        Property property=repobj.getProperty();
        if (property != null) {
          item=property.getItem();
        }
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
      Connection connection=((ConnectionItem)item).getConnection();
      for (      org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
        if (table.getLabel().equals(tableLabel)) {
          metadataTable=ConvertionHelper.convert(table);
          break;
        }
      }
    }
    if (metadataTable != null) {
      realTableName=metadataTable.getTableName();
    }
  }
  connParameters.setSchemaName(QueryUtil.getTableName(elem,connParameters.getMetadataTable(),TalendTextUtils.removeQuotes(schema),type,realTableName));
}

Fixed version (ground truth):
private void setAllConnectionParameters(String typ,IElement element){
  String type=null;
  ExtractMetaDataUtils extractMeta=ExtractMetaDataUtils.getInstance();
  if (typ != null && !typ.equals("String_Node_Str")) {
    type=typ;
  }
 else {
    type=getValueFromRepositoryName(element,"String_Node_Str");
  }
  if (type.equals("String_Node_Str") || type.contains("String_Node_Str")) {
    IElementParameter ele=element.getElementParameter("String_Node_Str");
    if (ele != null) {
      type=(String)ele.getValue();
    }
 else {
      type="String_Node_Str";
    }
  }
  if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element,"String_Node_Str").equals("String_Node_Str")) {
    type=EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
  }
  if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
    type=EDatabaseTypeName.GENERAL_JDBC.getXmlName();
  }
  if (StringUtils.trimToNull(type) != null) {
    connParameters.setDbType(type);
  }
  String frameWorkKey=getValueFromRepositoryName(element,"String_Node_Str");
  connParameters.setFrameworkType(frameWorkKey);
  String schema=getValueFromRepositoryName(element,EConnectionParameterName.SCHEMA.getName());
  connParameters.setSchema(schema);
  String userName=getValueFromRepositoryName(element,EConnectionParameterName.USERNAME.getName());
  connParameters.setUserName(userName);
  String password=getValueFromRepositoryName(element,EConnectionParameterName.PASSWORD.getName());
  connParameters.setPassword(password);
  String host=getValueFromRepositoryName(element,EConnectionParameterName.SERVER_NAME.getName());
  connParameters.setHost(host);
  String port=getValueFromRepositoryName(element,EConnectionParameterName.PORT.getName());
  connParameters.setPort(port);
  boolean https=Boolean.parseBoolean(getValueFromRepositoryName(element,EConnectionParameterName.HTTPS.getName()));
  connParameters.setHttps(https);
  boolean isOracleOCI=type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
  if (isOracleOCI) {
    String localServiceName=getValueFromRepositoryNameAndParameterName(element,EConnectionParameterName.SID.getName(),EParameterName.LOCAL_SERVICE_NAME.getName());
    connParameters.setLocalServiceName(localServiceName);
  }
  String datasource=getValueFromRepositoryName(element,EConnectionParameterName.DATASOURCE.getName());
  connParameters.setDatasource(datasource);
  String dbName=getValueFromRepositoryName(element,EConnectionParameterName.SID.getName());
  connParameters.setDbName(dbName);
  if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
    String file=getValueFromRepositoryName(element,EConnectionParameterName.FILE.getName());
    connParameters.setFilename(file);
  }
  String dir=getValueFromRepositoryName(element,EConnectionParameterName.DIRECTORY.getName());
  if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
    dir=getValueFromRepositoryName(elem,EConnectionParameterName.DBPATH.getName());
  }
  connParameters.setDirectory(dir);
  String url=getValueFromRepositoryName(element,EConnectionParameterName.URL.getName());
  if (StringUtils.isEmpty(url)) {
    if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
      url=getValueFromRepositoryName(element,"String_Node_Str" + EConnectionParameterName.URL.getName());
    }
  }
  connParameters.setUrl(TalendTextUtils.removeQuotes(url));
  String driverJar=getValueFromRepositoryName(element,EConnectionParameterName.DRIVER_JAR.getName());
  connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
  String driverClass=getValueFromRepositoryName(element,EConnectionParameterName.DRIVER_CLASS.getName());
  connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
  if (driverClass != null && !"String_Node_Str".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
    if (driverClass.startsWith("String_Node_Str") && driverClass.endsWith("String_Node_Str")) {
      driverClass=TalendTextUtils.removeQuotes(driverClass);
    }
    String dbTypeByClassName="String_Node_Str";
    if (driverJar != null && !"String_Node_Str".equals(driverJar)) {
      dbTypeByClassName=extractMeta.getDbTypeByClassNameAndDriverJar(driverClass,driverJar);
    }
 else {
      dbTypeByClassName=extractMeta.getDbTypeByClassName(driverClass);
    }
    if (dbTypeByClassName != null) {
      connParameters.setDbType(dbTypeByClassName);
    }
  }
  String jdbcProps=getValueFromRepositoryName(element,EConnectionParameterName.PROPERTIES_STRING.getName());
  connParameters.setJdbcProperties(jdbcProps);
  String realTableName=null;
  if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
    final Object propertyValue=elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
    IMetadataTable metadataTable=null;
    String connectionId=propertyValue.toString().split("String_Node_Str")[0];
    String tableLabel=propertyValue.toString().split("String_Node_Str")[1];
    IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
    Item item=null;
    try {
      IRepositoryViewObject repobj=factory.getLastVersion(connectionId);
      if (repobj != null) {
        Property property=repobj.getProperty();
        if (property != null) {
          item=property.getItem();
        }
      }
    }
 catch (    PersistenceException e) {
      ExceptionHandler.process(e);
    }
    if (item != null && item instanceof ConnectionItem) {
      Connection connection=((ConnectionItem)item).getConnection();
      for (      org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
        if (table.getLabel().equals(tableLabel)) {
          metadataTable=ConvertionHelper.convert(table);
          break;
        }
      }
    }
    if (metadataTable != null) {
      realTableName=metadataTable.getTableName();
    }
  }
  connParameters.setSchemaName(QueryUtil.getTableName(elem,connParameters.getMetadataTable(),TalendTextUtils.removeQuotes(schema),type,realTableName));
}