Program: 102219
Project: 102219
Buggy source:
/** 
 * Find an existing index that is a match for the supplied information, and optionally create one if needed (and the index should be created).
 * @param table
 * @param spec
 * @param tableNode
 * @param context
 * @param createIfRequired
 * @return
 */
protected Index findIndex(final Table table,final IndexSpec spec,final JdbcTable tableNode,final Context context,final boolean createIfRequired,List problems){
  final EObject tableOwner=table.eContainer();
  if (tableOwner != null) {
    List existingIndexes=null;
    if (tableOwner instanceof Catalog) {
      existingIndexes=((Catalog)tableOwner).getIndexes();
    }
 else     if (tableOwner instanceof Schema) {
      existingIndexes=((Schema)tableOwner).getIndexes();
    }
    final Iterator iter=existingIndexes.iterator();
    while (iter.hasNext()) {
      final Index index=(Index)iter.next();
      final boolean isMatch=isMatchingIndex(index,spec);
      if (isMatch) {
        setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
        return index;
      }
    }
  }
 else {
    final Resource resource=table.eResource();
    if (resource != null) {
      final Iterator iter=resource.getContents().iterator();
      while (iter.hasNext()) {
        final Object rootObj=iter.next();
        if (rootObj instanceof Index) {
          final Index index=(Index)rootObj;
          if (isMatchingIndex(index,spec)) {
            setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
            return index;
          }
        }
      }
    }
  }
  if (table instanceof BaseTable) {
    final String objectName=convertName(spec.indexName,context);
    final PrimaryKey pk=((BaseTable)table).getPrimaryKey();
    if (pk != null) {
      if (objectName.equals(pk.getName())) {
        return null;
      }
    }
  }
  final Index index=this.factory.createIndex();
  if (tableOwner != null) {
    if (tableOwner instanceof Catalog) {
      index.setCatalog((Catalog)tableOwner);
    }
 else     if (tableOwner instanceof Schema) {
      index.setSchema((Schema)tableOwner);
    }
  }
 else {
    final Resource resource=table.eResource();
    CoreArgCheck.isNotNull(resource);
    resource.getContents().add(index);
  }
  setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
  index.setUnique(!spec.nonUnique);
  index.getColumns().addAll(spec.columns);
  index.setFilterCondition(spec.filterCondition);
  return index;
}

Fixed version (ground truth):
/** 
 * Find an existing index that is a match for the supplied information, and optionally create one if needed (and the index should be created).
 * @param table
 * @param spec
 * @param tableNode
 * @param context
 * @param createIfRequired
 * @return
 */
protected Index findIndex(final Table table,final IndexSpec spec,final JdbcTable tableNode,final Context context,final boolean createIfRequired,List problems){
  final EObject tableOwner=table.eContainer();
  if (tableOwner != null) {
    List existingIndexes=null;
    if (tableOwner instanceof Catalog) {
      existingIndexes=((Catalog)tableOwner).getIndexes();
    }
 else     if (tableOwner instanceof Schema) {
      existingIndexes=((Schema)tableOwner).getIndexes();
    }
    final Iterator iter=existingIndexes.iterator();
    while (iter.hasNext()) {
      final Index index=(Index)iter.next();
      final boolean isMatch=isMatchingIndex(index,spec);
      if (isMatch) {
        setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
        return index;
      }
    }
  }
 else {
    final Resource resource=table.eResource();
    if (resource != null) {
      final Iterator iter=resource.getContents().iterator();
      while (iter.hasNext()) {
        final Object rootObj=iter.next();
        if (rootObj instanceof Index) {
          final Index index=(Index)rootObj;
          if (isMatchingIndex(index,spec)) {
            setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
            return index;
          }
        }
      }
    }
  }
  if (table instanceof BaseTable) {
    final String objectName=convertName(spec.indexName,context);
    final PrimaryKey pk=((BaseTable)table).getPrimaryKey();
    if (pk != null) {
      if (objectName.equals(pk.getName())) {
        return null;
      }
    }
  }
  final Index index=this.factory.createIndex();
  if (tableOwner != null) {
    if (tableOwner instanceof Catalog) {
      index.setCatalog((Catalog)tableOwner);
    }
 else     if (tableOwner instanceof Schema) {
      index.setSchema((Schema)tableOwner);
    }
  }
 else {
    final Resource resource=table.eResource();
    CoreArgCheck.isNotNull(resource);
    resource.getContents().add(index);
  }
  setNameAndNameInSource(index,spec.indexName,tableNode,context,problems);
  String quoteStr=getQuoteString(context,problems);
  String nis=index.getNameInSource() + '.' + quoteStr+ spec.indexName+ quoteStr;
  index.setNameInSource(nis);
  index.setUnique(!spec.nonUnique);
  index.getColumns().addAll(spec.columns);
  index.setFilterCondition(spec.filterCondition);
  return index;
}