Program: 130109
Project: 130109
Buggy source:
private List<TableNode> getTableNodeInfo(){
  List<TableNode> tableNodes=new ArrayList<TableNode>();
  DatabaseConnection connection=(DatabaseConnection)metadataconnection.getCurrentConnection();
  List<Catalog> catalogs=ConnectionHelper.getCatalogs(connection);
  if (catalogs.isEmpty()) {
    List<Schema> schemas=ConnectionHelper.getSchema(connection);
    if (schemas.isEmpty()) {
      return tableNodes;
    }
 else {
      for (      Schema s : schemas) {
        TableNode schemaNode=new TableNode();
        schemaNode.setSchema(s);
        schemaNode.setValue(s.getName());
        schemaNode.setType(TableNode.SCHEMA);
        schemaNode.setMetadataConn(metadataconnection);
        schemaNode.setParas(tableInfoParameters);
        if (s.getName() != null && !s.getName().equals(MetadataConnectionUtils.FAKE_SCHEMA_SYNONYMS)) {
          tableNodes.add(schemaNode);
        }
      }
    }
  }
 else {
    for (    Catalog c : catalogs) {
      TableNode catalogNode=new TableNode();
      catalogNode.setCatalog(c);
      catalogNode.setValue(c.getName());
      catalogNode.setType(TableNode.CATALOG);
      catalogNode.setMetadataConn(metadataconnection);
      catalogNode.setParas(tableInfoParameters);
      List<Schema> schemas=CatalogHelper.getSchemas(c);
      if (schemas.isEmpty()) {
        tableNodes.add(catalogNode);
      }
 else {
        for (        Schema s : schemas) {
          TableNode schemaNode=new TableNode();
          schemaNode.setSchema(s);
          schemaNode.setValue(s.getName());
          schemaNode.setType(TableNode.SCHEMA);
          schemaNode.setMetadataConn(metadataconnection);
          schemaNode.setParas(tableInfoParameters);
          schemaNode.setParent(catalogNode);
          catalogNode.addChild(schemaNode);
        }
        tableNodes.add(catalogNode);
      }
    }
  }
  return tableNodes;
}

Fixed version (ground truth):
private List<TableNode> getTableNodeInfo(){
  List<TableNode> tableNodes=new ArrayList<TableNode>();
  DatabaseConnection connection=(DatabaseConnection)metadataconnection.getCurrentConnection();
  List<Catalog> catalogs=ConnectionHelper.getCatalogs(connection);
  if (catalogs.isEmpty()) {
    List<Schema> schemas=ConnectionHelper.getSchema(connection);
    String specifiedSchema=null;
    if (ManagerConnection.isSchemaFromSidOrDatabase(EDatabaseTypeName.getTypeFromDbType(connection.getDatabaseType()))) {
      String sid=connection.getSID();
      if (sid != null && sid.length() > 0) {
        specifiedSchema=sid;
      }
    }
    if (schemas.isEmpty()) {
      return tableNodes;
    }
 else {
      EDatabaseTypeName dbType=EDatabaseTypeName.getTypeFromDbType(connection.getDatabaseType());
      for (      Schema s : schemas) {
        TableNode schemaNode=new TableNode();
        schemaNode.setSchema(s);
        schemaNode.setValue(s.getName());
        schemaNode.setType(TableNode.SCHEMA);
        schemaNode.setMetadataConn(metadataconnection);
        schemaNode.setParas(tableInfoParameters);
        if (s.getName() != null && !s.getName().equals(MetadataConnectionUtils.FAKE_SCHEMA_SYNONYMS)) {
          boolean canAdd=true;
          if (specifiedSchema != null) {
            if (ManagerConnection.isSchemaCaseSensitive(dbType)) {
              if (!s.getName().equals(specifiedSchema)) {
                canAdd=false;
              }
            }
 else {
              if (!s.getName().toLowerCase().equals(specifiedSchema.toLowerCase())) {
                canAdd=false;
              }
            }
          }
          if (canAdd) {
            tableNodes.add(schemaNode);
          }
        }
      }
    }
  }
 else {
    for (    Catalog c : catalogs) {
      TableNode catalogNode=new TableNode();
      catalogNode.setCatalog(c);
      catalogNode.setValue(c.getName());
      catalogNode.setType(TableNode.CATALOG);
      catalogNode.setMetadataConn(metadataconnection);
      catalogNode.setParas(tableInfoParameters);
      List<Schema> schemas=CatalogHelper.getSchemas(c);
      if (schemas.isEmpty()) {
        tableNodes.add(catalogNode);
      }
 else {
        for (        Schema s : schemas) {
          TableNode schemaNode=new TableNode();
          schemaNode.setSchema(s);
          schemaNode.setValue(s.getName());
          schemaNode.setType(TableNode.SCHEMA);
          schemaNode.setMetadataConn(metadataconnection);
          schemaNode.setParas(tableInfoParameters);
          schemaNode.setParent(catalogNode);
          catalogNode.addChild(schemaNode);
        }
        tableNodes.add(catalogNode);
      }
    }
  }
  return tableNodes;
}