Program: 138708
Project: 138708
Buggy source:
private void initializeSchemaLow() throws SQLException {
  String dbName=getDbConnectionParameter() == null ? null : getDbConnectionParameter().getDbName();
  if (SupportDBUrlType.ORACLEWITHSIDDEFAULTURL.getLanguage().equals(dbms.getDbmsName()) && dbConnection instanceof DatabaseConnection) {
    String otherParameter=getDbConnectionParameter().getOtherParameter() == null ? null : getDbConnectionParameter().getOtherParameter().toUpperCase();
    if (otherParameter != null && !getDbConnectionParameter().isRetrieveAllMetadata()) {
      dbName=otherParameter;
    }
 else {
      dbName=((DatabaseConnection)dbConnection).getUsername().toUpperCase();
    }
  }
  if (!this.catalogsInitialized) {
    initializeCatalog();
  }
  Map<String,List<Schema>> catalog2schemas=null;
  if (this.connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) {
    catalog2schemas=DatabaseContentRetriever.getMSSQLSchemas(this.connection);
  }
 else {
    catalog2schemas=DatabaseContentRetriever.getSchemas(this.connection);
  }
  boolean odbcIngres=this.connection.getMetaData().getDriverName().startsWith(DatabaseConstant.ODBC_INGRES_DRIVER_NAME);
  Set<String> catNames=catalog2schemas.keySet();
  for (  String catName : catNames) {
    List<Schema> schemas=catalog2schemas.get(catName);
    if (catName != null) {
      if (schemas != null) {
        Catalog catalog=getCatalog(catName);
        if (catalog != null && schemas != null) {
          if (!(schemas.size() == 1 && schemas.get(0) == null)) {
            CatalogHelper.addSchemas(schemas,catalog);
          }
        }
      }
    }
 else {
      List<Schema> retrievedSchemas=new ArrayList<Schema>();
      for (      Schema schema : schemas) {
        if (retrieveCatalogSchema(dbName,schema.getName()) || odbcIngres) {
          retrievedSchemas.add(schema);
        }
      }
      this.schemata.addAll(retrievedSchemas);
      if ((ConnectionUtils.isPostgresql(this.connection) && catNames.size() == 1 && this.name2catalog.size() == 1) || odbcIngres) {
        Catalog cat=this.name2catalog.values().iterator().next();
        CatalogHelper.addSchemas(retrievedSchemas,cat);
      }
    }
  }
  schemaInitialized=true;
}

Fixed version (ground truth):
private void initializeSchemaLow() throws SQLException {
  String dbName=dbConnectionParameter == null ? null : dbConnectionParameter.getDbName();
  if (SupportDBUrlType.ORACLEWITHSIDDEFAULTURL.getLanguage().equals(dbms.getDbmsName()) && dbConnection instanceof DatabaseConnection) {
    String otherParameter=null;
    if (dbConnectionParameter != null && dbConnectionParameter.getOtherParameter() != null) {
      otherParameter=dbConnectionParameter.getOtherParameter().toUpperCase();
    }
    if (otherParameter != null && !dbConnectionParameter.isRetrieveAllMetadata()) {
      dbName=otherParameter;
    }
 else {
      dbName=((DatabaseConnection)dbConnection).getUsername().toUpperCase();
    }
  }
  if (!this.catalogsInitialized) {
    initializeCatalog();
  }
  Map<String,List<Schema>> catalog2schemas=null;
  if (this.connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) {
    catalog2schemas=DatabaseContentRetriever.getMSSQLSchemas(this.connection);
  }
 else {
    catalog2schemas=DatabaseContentRetriever.getSchemas(this.connection);
  }
  boolean odbcIngres=this.connection.getMetaData().getDriverName().startsWith(DatabaseConstant.ODBC_INGRES_DRIVER_NAME);
  Set<String> catNames=catalog2schemas.keySet();
  for (  String catName : catNames) {
    List<Schema> schemas=catalog2schemas.get(catName);
    if (catName != null) {
      if (schemas != null) {
        Catalog catalog=getCatalog(catName);
        if (catalog != null && schemas != null) {
          if (!(schemas.size() == 1 && schemas.get(0) == null)) {
            CatalogHelper.addSchemas(schemas,catalog);
          }
        }
      }
    }
 else {
      List<Schema> retrievedSchemas=new ArrayList<Schema>();
      for (      Schema schema : schemas) {
        if (retrieveCatalogSchema(dbName,schema.getName()) || odbcIngres) {
          retrievedSchemas.add(schema);
        }
      }
      this.schemata.addAll(retrievedSchemas);
      if ((ConnectionUtils.isPostgresql(this.connection) && catNames.size() == 1 && this.name2catalog.size() == 1) || odbcIngres) {
        Catalog cat=this.name2catalog.values().iterator().next();
        CatalogHelper.addSchemas(retrievedSchemas,cat);
      }
    }
  }
  schemaInitialized=true;
}