Program: 102220
Project: 102220
Buggy source:
/** 
 * @see org.teiid.designer.jdbc.relational.impl.RelationalModelProcessorImpl#createIndexes(org.teiid.designer.jdbc.metadata.JdbcTable,org.teiid.designer.metamodels.relational.Table,org.teiid.designer.jdbc.relational.impl.Context,java.util.List)
 * @since 4.2
 */
@Override protected List createIndexes(final JdbcTable tableNode,final Table table,final Context context,final List problems){
  final List indexes=super.createIndexes(tableNode,table,context,problems);
  if (table instanceof BaseTable) {
    final BaseTable theTable=(BaseTable)table;
    final PrimaryKey pk=theTable.getPrimaryKey();
    if (pk != null) {
      final String pkName=pk.getName();
      if (pkName == null || pkName.trim().length() != 0) {
        final List pkColumns=pk.getColumns();
        boolean foundMatchingIndex=false;
        final Iterator iter=indexes.iterator();
        while (iter.hasNext()) {
          final Index index=(Index)iter.next();
          final String indexName=index.getName();
          if (indexName == null || indexName.trim().length() == 0) {
            continue;
          }
          final List indexColumns=index.getColumns();
          if (indexColumns.size() == pkColumns.size()) {
            final Iterator indexColumnIter=indexColumns.iterator();
            final Iterator pkColumnIter=pkColumns.iterator();
            while (pkColumnIter.hasNext() && indexColumnIter.hasNext()) {
              final Column indexColumn=(Column)indexColumnIter.next();
              final Column pkColumn=(Column)pkColumnIter.next();
              if (indexColumn != pkColumn) {
                break;
              }
            }
            foundMatchingIndex=true;
          }
          if (foundMatchingIndex) {
            setNameAndNameInSource(pk,indexName,tableNode,context,problems);
            break;
          }
        }
      }
    }
  }
  return indexes;
}

Fixed version (ground truth):
/** 
 * @see org.teiid.designer.jdbc.relational.impl.RelationalModelProcessorImpl#createIndexes(org.teiid.designer.jdbc.metadata.JdbcTable,org.teiid.designer.metamodels.relational.Table,org.teiid.designer.jdbc.relational.impl.Context,java.util.List)
 * @since 4.2
 */
@Override protected List createIndexes(final JdbcTable tableNode,final Table table,final Context context,final List problems){
  final List indexes=super.createIndexes(tableNode,table,context,problems);
  if (table instanceof BaseTable) {
    final BaseTable theTable=(BaseTable)table;
    final PrimaryKey pk=theTable.getPrimaryKey();
    if (pk != null) {
      final String pkName=pk.getName();
      if (pkName == null || pkName.trim().length() == 0) {
        final List pkColumns=pk.getColumns();
        boolean foundMatchingIndex=false;
        final Iterator iter=indexes.iterator();
        while (iter.hasNext()) {
          final Index index=(Index)iter.next();
          final String indexName=index.getName();
          if (indexName == null || indexName.trim().length() == 0) {
            continue;
          }
          final List indexColumns=index.getColumns();
          if (indexColumns.size() == pkColumns.size()) {
            final Iterator indexColumnIter=indexColumns.iterator();
            final Iterator pkColumnIter=pkColumns.iterator();
            while (pkColumnIter.hasNext() && indexColumnIter.hasNext()) {
              final Column indexColumn=(Column)indexColumnIter.next();
              final Column pkColumn=(Column)pkColumnIter.next();
              if (indexColumn != pkColumn) {
                break;
              }
            }
            foundMatchingIndex=true;
          }
          if (foundMatchingIndex) {
            setNameAndNameInSource(pk,indexName,tableNode,context,problems);
            break;
          }
        }
      }
    }
  }
  return indexes;
}