Program: 66428
Project: 66428
Buggy source:
/** 
 * INTERNAL: Create primary key values to be used for cache lookup.  The map of primary keys on the reference is keyed on the reference descriptors primary key field names.  Each of these primary keys contains all of the values for a particular key - in the order that they we read in from the document.  For example, if the key field names are A, B, and C, and there are three reference object instances, then the hashmap would have the following: (A=[1,2,3], B=[X,Y,Z], C=[Jim, Joe, Jane]).  If the primary key field names on the reference descriptor contained [B, C, A], then the result of this method call would be reference.primaryKeys=([X, Jim, 1], [Y, Joe, 2], [Z, Jane, 3]).
 * @param reference
 */
private void createPKVectorsFromMap(Reference reference){
  XMLCollectionReferenceMapping mapping=(XMLCollectionReferenceMapping)reference.getMapping();
  Vector pks=new Vector();
  Vector pkFields=mapping.getReferenceDescriptor().getPrimaryKeyFieldNames();
  if (pkFields.size() <= 0) {
    return;
  }
  CacheId pkVals;
  boolean init=true;
  for (Iterator pkFieldNameIt=pkFields.iterator(); pkFieldNameIt.hasNext(); ) {
    pkVals=(CacheId)reference.getPrimaryKeyMap().get(pkFieldNameIt.next());
    if (pkVals == null) {
      return;
    }
    if (init) {
      for (int i=0; i < pkVals.getPrimaryKey().length; i++) {
        pks.add(new CacheId(new Object[0]));
      }
      init=false;
    }
    for (int i=0; i < pkVals.getPrimaryKey().length; i++) {
      Object val=pkVals.getPrimaryKey()[i];
      ((CacheId)pks.get(i)).add(val);
    }
  }
  reference.primaryKey=pks;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Create primary key values to be used for cache lookup.  The map of primary keys on the reference is keyed on the reference descriptors primary key field names.  Each of these primary keys contains all of the values for a particular key - in the order that they we read in from the document.  For example, if the key field names are A, B, and C, and there are three reference object instances, then the hashmap would have the following: (A=[1,2,3], B=[X,Y,Z], C=[Jim, Joe, Jane]).  If the primary key field names on the reference descriptor contained [B, C, A], then the result of this method call would be reference.primaryKeys=([X, Jim, 1], [Y, Joe, 2], [Z, Jane, 3]).
 * @param reference
 */
private void createPKVectorsFromMap(Reference reference,XMLCollectionReferenceMapping mapping){
  ClassDescriptor referenceDescriptor=mapping.getReferenceDescriptor();
  Vector pks=new Vector();
  if (null == referenceDescriptor) {
    CacheId pkVals=(CacheId)reference.getPrimaryKeyMap().get(null);
    if (null == pkVals) {
      return;
    }
    for (int x=0; x < pkVals.getPrimaryKey().length; x++) {
      Object[] values=new Object[1];
      values[0]=pkVals.getPrimaryKey()[x];
      pks.add(new CacheId(values));
    }
  }
 else {
    Vector pkFields=referenceDescriptor.getPrimaryKeyFieldNames();
    if (pkFields.isEmpty()) {
      return;
    }
    boolean init=true;
    for (Iterator pkFieldNameIt=pkFields.iterator(); pkFieldNameIt.hasNext(); ) {
      CacheId pkVals=(CacheId)reference.getPrimaryKeyMap().get(pkFieldNameIt.next());
      if (pkVals == null) {
        return;
      }
      if (init) {
        for (int i=0; i < pkVals.getPrimaryKey().length; i++) {
          pks.add(new CacheId(new Object[0]));
        }
        init=false;
      }
      for (int i=0; i < pkVals.getPrimaryKey().length; i++) {
        Object val=pkVals.getPrimaryKey()[i];
        ((CacheId)pks.get(i)).add(val);
      }
    }
  }
  reference.setPrimaryKey(pks);
}