Program: 129987
Project: 129987
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);
        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);
    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;
}