Program: 25057
Project: 25057
Buggy source:
/** 
 * Searches all   {@link DBColumn} elements which have the given catalog, schema, table and column name, with the specified case sensitivity.
 * @param catalog			Catalog name.
 * @param schema			Schema name.
 * @param table				Table name.
 * @param column			Column name.
 * @param caseSensitivity	Case sensitivity for each column parts (one bit by part ; 0=sensitive,1=insensitive ; see {@link IdentifierField} for more details).
 * @return					The list of all matching {@link DBColumn} elements.
 * @see IdentifierField
 */
public ArrayList<DBColumn> search(final String catalog,final String schema,final String table,final String column,final byte caseSensitivity){
  ArrayList<DBColumn> tmpResult=get(column,IdentifierField.COLUMN.isCaseSensitive(caseSensitivity));
  if (table != null) {
    String tableName=null;
    ArrayList<String> aliasMatches=null;
    if (IdentifierField.TABLE.isCaseSensitive(caseSensitivity)) {
      tableName=tableAliases.get(table);
      if (tableName == null)       tableName=table;
    }
 else {
      aliasMatches=mapAliases.get(table.toLowerCase());
      if (aliasMatches == null || aliasMatches.isEmpty())       tableName=table;
    }
    ArrayList<DBColumn> result=new ArrayList<DBColumn>();
    for (    DBColumn match : tmpResult) {
      Iterator<DBTable> itMatchTables;
      if (ADQLJoin.isCommonColumn(match))       itMatchTables=((DBCommonColumn)match).getCoveredTables();
 else       itMatchTables=new SingleIterator<DBTable>(match.getTable());
      DBTable matchTable;
      while (itMatchTables.hasNext()) {
        matchTable=itMatchTables.next();
        if (aliasMatches == null) {
          if (IdentifierField.TABLE.isCaseSensitive(caseSensitivity)) {
            if (!matchTable.getADQLName().equals(tableName))             continue;
          }
 else {
            if (!matchTable.getADQLName().equalsIgnoreCase(tableName))             continue;
          }
        }
 else {
          boolean foundAlias=false;
          String temp;
          for (int a=0; !foundAlias && a < aliasMatches.size(); a++) {
            temp=tableAliases.get(aliasMatches.get(a));
            if (temp != null)             foundAlias=matchTable.getADQLName().equalsIgnoreCase(temp);
          }
          if (!foundAlias)           continue;
        }
        if (schema != null && matchTable.getADQLSchemaName() != null) {
          if (IdentifierField.SCHEMA.isCaseSensitive(caseSensitivity)) {
            if (!matchTable.getADQLSchemaName().equals(schema))             continue;
          }
 else {
            if (!matchTable.getADQLSchemaName().equalsIgnoreCase(schema))             continue;
          }
          if (catalog != null) {
            if (IdentifierField.CATALOG.isCaseSensitive(caseSensitivity)) {
              if (!matchTable.getADQLCatalogName().equals(catalog))               continue;
            }
 else {
              if (!matchTable.getADQLCatalogName().equalsIgnoreCase(catalog))               continue;
            }
          }
        }
        DBColumn goodMatch=matchTable.getColumn(match.getADQLName(),true);
        result.add(goodMatch);
      }
    }
    return result;
  }
 else {
    if (tmpResult.size() > 1) {
      ArrayList<DBColumn> result=new ArrayList<DBColumn>(tmpResult.size());
      for (int i=0; i < tmpResult.size(); i++) {
        if (ADQLJoin.isCommonColumn(tmpResult.get(i))) {
          DBCommonColumn commonColumn=(DBCommonColumn)tmpResult.remove(i);
          result.add(commonColumn);
          Iterator<DBTable> itCoveredTables=commonColumn.getCoveredTables();
          while (itCoveredTables.hasNext())           tmpResult.add(itCoveredTables.next().getColumn(column,true));
        }
      }
      if (result.size() == 1)       return result;
    }
    return tmpResult;
  }
}

Fixed version (ground truth):
/** 
 * Searches all   {@link DBColumn} elements which have the given catalog, schema, table and column name, with the specified case sensitivity.
 * @param catalog			Catalog name.
 * @param schema			Schema name.
 * @param table				Table name.
 * @param column			Column name.
 * @param caseSensitivity	Case sensitivity for each column parts (one bit by part ; 0=sensitive,1=insensitive ; see {@link IdentifierField} for more details).
 * @return					The list of all matching {@link DBColumn} elements.
 * @see IdentifierField
 */
public ArrayList<DBColumn> search(final String catalog,final String schema,final String table,final String column,final byte caseSensitivity){
  ArrayList<DBColumn> tmpResult=get(column,IdentifierField.COLUMN.isCaseSensitive(caseSensitivity));
  if (table != null) {
    String tableName=null;
    ArrayList<String> aliasMatches=null;
    if (IdentifierField.TABLE.isCaseSensitive(caseSensitivity)) {
      tableName=tableAliases.get(table);
      if (tableName == null)       tableName=table;
    }
 else {
      aliasMatches=mapAliases.get(table.toLowerCase());
      if (aliasMatches == null || aliasMatches.isEmpty())       tableName=table;
    }
    ArrayList<DBColumn> result=new ArrayList<DBColumn>();
    for (    DBColumn match : tmpResult) {
      Iterator<DBTable> itMatchTables;
      if (ADQLJoin.isCommonColumn(match))       itMatchTables=((DBCommonColumn)match).getCoveredTables();
 else       itMatchTables=new SingleIterator<DBTable>(match.getTable());
      DBTable matchTable;
      while (itMatchTables.hasNext()) {
        matchTable=itMatchTables.next();
        if (aliasMatches == null) {
          if (IdentifierField.TABLE.isCaseSensitive(caseSensitivity)) {
            if (!matchTable.getADQLName().equals(tableName))             continue;
          }
 else {
            if (!matchTable.getADQLName().equalsIgnoreCase(tableName))             continue;
          }
        }
 else {
          boolean foundAlias=false;
          String temp;
          for (int a=0; !foundAlias && a < aliasMatches.size(); a++) {
            temp=tableAliases.get(aliasMatches.get(a));
            if (temp != null)             foundAlias=matchTable.getADQLName().equalsIgnoreCase(temp);
          }
          if (!foundAlias)           continue;
        }
        if (schema != null) {
          if (matchTable.getADQLSchemaName() == null)           continue;
          if (IdentifierField.SCHEMA.isCaseSensitive(caseSensitivity)) {
            if (!matchTable.getADQLSchemaName().equals(schema))             continue;
          }
 else {
            if (!matchTable.getADQLSchemaName().equalsIgnoreCase(schema))             continue;
          }
          if (catalog != null) {
            if (matchTable.getADQLCatalogName() == null)             continue;
            if (IdentifierField.CATALOG.isCaseSensitive(caseSensitivity)) {
              if (!matchTable.getADQLCatalogName().equals(catalog))               continue;
            }
 else {
              if (!matchTable.getADQLCatalogName().equalsIgnoreCase(catalog))               continue;
            }
          }
        }
        DBColumn goodMatch=matchTable.getColumn(match.getADQLName(),true);
        result.add(goodMatch);
      }
    }
    return result;
  }
 else {
    if (tmpResult.size() > 1) {
      ArrayList<DBColumn> result=new ArrayList<DBColumn>(tmpResult.size());
      for (int i=0; i < tmpResult.size(); i++) {
        if (ADQLJoin.isCommonColumn(tmpResult.get(i))) {
          DBCommonColumn commonColumn=(DBCommonColumn)tmpResult.remove(i);
          result.add(commonColumn);
          Iterator<DBTable> itCoveredTables=commonColumn.getCoveredTables();
          while (itCoveredTables.hasNext())           tmpResult.add(itCoveredTables.next().getColumn(column,true));
        }
      }
      if (result.size() == 1)       return result;
    }
    return tmpResult;
  }
}