Program: 128556
Project: 128556
Buggy source:
public List<Catalog> fillCatalogs(Connection dbConn,DatabaseMetaData dbJDBCMetadata,List<String> catalogFilter){
}

Fixed version (ground truth):
public List<Catalog> fillCatalogs(Connection dbConn,DatabaseMetaData dbJDBCMetadata,List<String> catalogFilter){
  List<Catalog> catalogList=new ArrayList<Catalog>();
  if (dbJDBCMetadata == null) {
    return null;
  }
  if (ConnectionUtils.isPostgresql(dbJDBCMetadata)) {
    return fillPostgresqlCatalogs(dbConn,dbJDBCMetadata,catalogList);
  }
  if (dbConn != null && dbConn.isContextMode()) {
    if (EDatabaseTypeName.MYSQL.getProduct().equals(((DatabaseConnection)dbConn).getProductId()) || EDatabaseTypeName.MSSQL.getProduct().equals(((DatabaseConnection)dbConn).getProductId()) || EDatabaseTypeName.MSSQL05_08.getProduct().equals(((DatabaseConnection)dbConn).getProductId())) {
      IMetadataConnection iMetadataCon=ConvertionHelper.convert(dbConn);
      if (iMetadataCon != null) {
        String catalogTemp=iMetadataCon.getDatabase();
        if ("String_Node_Str".equals(catalogTemp)) {
          catalogFilter.clear();
        }
      }
    }
  }
  try {
    if (dbJDBCMetadata.getDatabaseProductName() != null && dbJDBCMetadata.getDatabaseProductName().indexOf(EDatabaseTypeName.ORACLEFORSID.getProduct()) > -1) {
      return catalogList;
    }
    if (ConnectionUtils.isOdbcTeradata(dbJDBCMetadata)) {
      return catalogList;
    }
    ResultSet catalogNames=null;
    if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
      catalogNames=((SybaseDatabaseMetaData)dbJDBCMetadata).getCatalogs(((DatabaseConnection)dbConn).getUsername());
    }
 else {
      catalogNames=dbJDBCMetadata.getCatalogs();
    }
    List<String> filterList=new ArrayList<String>();
    if (catalogNames != null) {
      boolean isHive=MetadataConnectionUtils.isHive(dbJDBCMetadata);
      boolean isSybase=MetadataConnectionUtils.isSybase(dbJDBCMetadata);
      while (catalogNames.next()) {
        String catalogName=null;
        try {
          String temp=null;
          if (isHive) {
            temp=MetaDataConstants.TABLE_CAT.name();
          }
 else {
            temp=MetadataConnectionUtils.isOdbcPostgresql(dbJDBCMetadata) ? DatabaseConstant.ODBC_POSTGRESQL_CATALOG_NAME : MetaDataConstants.TABLE_CAT.name();
          }
          catalogName=catalogNames.getString(temp);
          if (!isHive && !MetadataConnectionUtils.isODBCCatalog(catalogName,dbJDBCMetadata)) {
            continue;
          }
        }
 catch (        Exception e) {
          log.warn(e,e);
          if (dbJDBCMetadata.getDatabaseProductName() != null && dbJDBCMetadata.getDatabaseProductName().toLowerCase().indexOf(DatabaseConstant.POSTGRESQL_PRODUCT_NAME) > -1) {
            catalogName="String_Node_Str";
          }
        }
        if (!isNullSID(dbConn) && dbConn != null) {
          String databaseOnConnWizard=((DatabaseConnection)dbConn).getSID();
          postFillCatalog(catalogList,filterList,TalendCWMService.getReadableName(dbConn,databaseOnConnWizard),dbConn);
          break;
        }
 else         if (isCreateElement(catalogFilter,catalogName)) {
          postFillCatalog(catalogList,filterList,catalogName,dbConn);
        }
      }
      catalogNames.close();
      if (!isHive) {
        List<Catalog> removeCatalogList=new ArrayList<Catalog>();
        for (        Catalog catalog : catalogList) {
          List<Schema> schemaList=new ArrayList<Schema>();
          try {
            schemaList=fillSchemaToCatalog(dbConn,dbJDBCMetadata,catalog,filterList);
            if (!schemaList.isEmpty() && schemaList.size() > 0) {
              CatalogHelper.addSchemas(schemaList,catalog);
            }
          }
 catch (          Throwable e) {
            removeCatalogList.add(catalog);
          }
        }
        if (isSybase && catalogFilter != null && !catalogFilter.isEmpty() && catalogFilter.size() > 0 && catalogList.isEmpty() && catalogList.size() == 0) {
          catalogFilter.clear();
          return fillCatalogs(dbConn,dbJDBCMetadata,catalogFilter);
        }
        catalogList.removeAll(removeCatalogList);
      }
      Set<MetadataTable> tableSet=ConnectionHelper.getTables(dbConn);
      List<Catalog> replaceCatalogs=new ArrayList<Catalog>();
      List<String> catalogName=new ArrayList<String>();
      for (      MetadataTable table : tableSet) {
        EObject eContainer=table.eContainer();
        if (eContainer != null) {
          if (eContainer instanceof Catalog) {
            Catalog c=(Catalog)eContainer;
            String name=c.getName();
            if (!catalogName.contains(name)) {
              replaceCatalogs.add(c);
              catalogName.add(name);
            }
          }
 else           if (eContainer instanceof Schema) {
            EObject parent=eContainer.eContainer();
            if (parent != null && parent instanceof Catalog) {
              Catalog c=(Catalog)parent;
              String name=c.getName();
              if (!catalogName.contains(name)) {
                List<Schema> filterSchemas=new ArrayList<Schema>();
                List<String> schemaName=new ArrayList<String>();
                List<Schema> schemas=CatalogHelper.getSchemas(c);
                for (                Schema schema : schemas) {
                  if (filterList != null) {
                    if (filterList.contains(schema.getName())) {
                      filterSchemas.add(schema);
                      schemaName.add(schema.getName());
                    }
 else                     if (schema.getOwnedElement() != null && !schema.getOwnedElement().isEmpty()) {
                      filterSchemas.add(schema);
                      schemaName.add(schema.getName());
                    }
                  }
                }
                for (                Catalog catalog : catalogList) {
                  if (catalog.getName().equals(name)) {
                    boolean added=false;
                    for (                    Schema schema : CatalogHelper.getSchemas(catalog)) {
                      if (!schemaName.contains(schema.getName())) {
                        filterSchemas.add(schema);
                        added=true;
                      }
                    }
                    if (added) {
                      break;
                    }
                  }
                }
                c.getOwnedElement().clear();
                CatalogHelper.addSchemas(filterSchemas,c);
                replaceCatalogs.add(c);
                catalogName.add(name);
              }
            }
          }
        }
      }
      if (this.isLinked() && !catalogList.isEmpty()) {
        ConnectionHelper.addCatalogs(catalogList,dbConn);
      }
      for (      Catalog catalog : replaceCatalogs) {
        List<Catalog> list=new ArrayList<Catalog>();
        String name=catalog.getName();
        Catalog c=(Catalog)ConnectionHelper.getPackage(name,dbConn,Catalog.class);
        if (c != null) {
          list.add(c);
          ConnectionHelper.removeCatalogs(list,dbConn);
          ConnectionHelper.addCatalog(catalog,dbConn);
        }
 else {
          ConnectionHelper.addCatalog(catalog,dbConn);
        }
      }
    }
  }
 catch (  SQLException e) {
    log.warn("String_Node_Str",e);
  }
  return catalogList;
}