Program: 68501
Project: 68501
Buggy source:
/** 
 * ADVANCED: Use this method when updating object attribute values, with unmapped objects Integer, String or others. in events to ensure that all required objects are updated.  EclipseLink will automatically update all objects and changesets involved.  EclipseLink will update the field, in the row, to have the new value for the field that this mapping maps to.  If the attribute being updated is within an aggregate then pass the updated aggregate and the attribute of the aggregate mapping into this method.
 */
public void updateAttributeAddObjectToCollection(String attributeName,Object mapKey,Object value){
  DatabaseMapping mapping=this.query.getDescriptor().getObjectBuilder().getMappingForAttributeName(attributeName);
  if (mapping == null) {
    throw DescriptorException.mappingForAttributeIsMissing(attributeName,getDescriptor());
  }
  Object clone=this.getObject();
  Object cloneValue=value;
  Object original=null;
  if ((this.eventCode == DescriptorEventManager.PostCloneEvent) || (this.eventCode == DescriptorEventManager.PostMergeEvent)) {
    original=this.getOriginalObject();
  }
  Object originalValue=value;
  ObjectChangeSet eventChangeSet=this.getChangeSet();
  Object valueForChangeSet=value;
  if ((this.query != null) && this.query.isObjectLevelModifyQuery()) {
    clone=((ObjectLevelModifyQuery)this.query).getObject();
    eventChangeSet=((ObjectLevelModifyQuery)this.query).getObjectChangeSet();
  }
  ClassDescriptor descriptor=getSession().getDescriptor(value.getClass());
  if (descriptor != null) {
    if (eventChangeSet != null) {
      valueForChangeSet=descriptor.getObjectBuilder().createObjectChangeSet(value,(UnitOfWorkChangeSet)eventChangeSet.getUOWChangeSet(),getSession());
    }
    if (original != null) {
      originalValue=((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(value);
    }
  }
  if (clone != null) {
    Object collection=mapping.getRealCollectionAttributeValueFromObject(clone,getSession());
    mapping.getContainerPolicy().addInto(mapKey,cloneValue,collection,getSession());
  }
  if (original != null) {
    Object collection=mapping.getRealCollectionAttributeValueFromObject(original,getSession());
    mapping.getContainerPolicy().addInto(mapKey,originalValue,collection,getSession());
  }
  if (getRecord() != null) {
    AbstractRecord tempRow=getDescriptor().getObjectBuilder().createRecord();
    mapping.writeFromObjectIntoRow(clone,tempRow,getSession());
    ((AbstractRecord)getRecord()).mergeFrom(tempRow);
  }
  if (eventChangeSet != null) {
    mapping.simpleAddToCollectionChangeRecord(mapKey,valueForChangeSet,eventChangeSet,getSession());
  }
}

Fixed version (ground truth):
/** 
 * ADVANCED: Use this method when updating object attribute values, with unmapped objects Integer, String or others. in events to ensure that all required objects are updated.  EclipseLink will automatically update all objects and changesets involved.  EclipseLink will update the field, in the row, to have the new value for the field that this mapping maps to.  If the attribute being updated is within an aggregate then pass the updated aggregate and the attribute of the aggregate mapping into this method.
 */
public void updateAttributeAddObjectToCollection(String attributeName,Object mapKey,Object value){
  DatabaseMapping mapping=this.query.getDescriptor().getObjectBuilder().getMappingForAttributeName(attributeName);
  if (mapping == null) {
    throw DescriptorException.mappingForAttributeIsMissing(attributeName,getDescriptor());
  }
  Object clone=this.getObject();
  Object cloneValue=value;
  Object original=null;
  if ((this.eventCode == DescriptorEventManager.PostCloneEvent) || (this.eventCode == DescriptorEventManager.PostMergeEvent)) {
    original=this.getOriginalObject();
  }
  Object originalValue=value;
  ObjectChangeSet eventChangeSet=this.getChangeSet();
  Object valueForChangeSet=value;
  if ((this.query != null) && this.query.isObjectLevelModifyQuery()) {
    clone=((ObjectLevelModifyQuery)this.query).getObject();
    eventChangeSet=((ObjectLevelModifyQuery)this.query).getObjectChangeSet();
  }
  ClassDescriptor descriptor=getSession().getDescriptor(value.getClass());
  if (descriptor != null) {
    if (eventChangeSet != null) {
      valueForChangeSet=descriptor.getObjectBuilder().createObjectChangeSet(value,(UnitOfWorkChangeSet)eventChangeSet.getUOWChangeSet(),getSession());
    }
    if (original != null) {
      originalValue=((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(value);
    }
  }
  if (clone != null) {
    Object collection=mapping.getRealCollectionAttributeValueFromObject(clone,getSession());
    mapping.getContainerPolicy().addInto(mapKey,cloneValue,collection,getSession());
  }
  if (original != null) {
    Object collection=mapping.getRealCollectionAttributeValueFromObject(original,getSession());
    mapping.getContainerPolicy().addInto(mapKey,originalValue,collection,getSession());
  }
  if (getRecord() != null) {
    AbstractRecord tempRow=getDescriptor().getObjectBuilder().createRecord(getSession());
    mapping.writeFromObjectIntoRow(clone,tempRow,getSession());
    ((AbstractRecord)getRecord()).mergeFrom(tempRow);
  }
  if (eventChangeSet != null) {
    mapping.simpleAddToCollectionChangeRecord(mapKey,valueForChangeSet,eventChangeSet,getSession());
  }
}