Program: 68321
Project: 68321
Buggy source:
/** 
 * INTERNAL: Either create a new change record or update the change record with the new value. This is used by attribute change tracking.
 */
public void updateChangeRecord(Object sourceClone,Object newValue,Object oldValue,ObjectChangeSet objectChangeSet,UnitOfWorkImpl uow) throws DescriptorException {
  AggregateChangeRecord changeRecord=(AggregateChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
  if (changeRecord == null) {
    changeRecord=new AggregateChangeRecord(objectChangeSet);
    changeRecord.setAttribute(this.getAttributeName());
    changeRecord.setMapping(this);
    objectChangeSet.addChange(changeRecord);
  }
  if (sourceClone.getClass().equals(objectChangeSet.getClassType(uow))) {
    ClassDescriptor referenceDescriptor=getReferenceDescriptor(newValue,uow);
    if (newValue == null) {
      changeRecord.setChangedObject(null);
      if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
        ((AggregateAttributeChangeListener)((ChangeTracker)oldValue)._persistence_getPropertyChangeListener()).setParentListener(null);
      }
      return;
    }
 else {
      UnitOfWorkChangeSet uowChangeSet=(UnitOfWorkChangeSet)objectChangeSet.getUOWChangeSet();
      ObjectChangeSet aggregateChangeSet=(ObjectChangeSet)uowChangeSet.getObjectChangeSetForClone(newValue);
      if (aggregateChangeSet != null) {
        aggregateChangeSet.clear();
      }
      if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
        ((AggregateAttributeChangeListener)((ChangeTracker)oldValue)._persistence_getPropertyChangeListener()).setParentListener(null);
        AggregateAttributeChangeListener newListener=(AggregateAttributeChangeListener)((ChangeTracker)newValue)._persistence_getPropertyChangeListener();
        if (newListener == null) {
          newListener=new AggregateAttributeChangeListener(referenceDescriptor,uow,((AttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener()),this.getAttributeName(),newValue);
          ((ChangeTracker)newValue)._persistence_setPropertyChangeListener(newListener);
        }
        newListener.setParentListener((AttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener());
      }
      changeRecord.setChangedObject(referenceDescriptor.getObjectChangePolicy().createObjectChangeSetThroughComparison(newValue,oldValue,uowChangeSet,(oldValue == null),uow,referenceDescriptor));
      referenceDescriptor.getObjectChangePolicy().setChangeSetOnListener((ObjectChangeSet)changeRecord.getChangedObject(),newValue);
    }
  }
 else {
    if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
      changeRecord.setChangedObject(((AggregateAttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener()).getObjectChangeSet());
    }
 else {
      changeRecord.setChangedObject(referenceDescriptor.getObjectChangePolicy().createObjectChangeSetThroughComparison(sourceClone,null,(UnitOfWorkChangeSet)objectChangeSet.getUOWChangeSet(),true,uow,referenceDescriptor));
    }
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Either create a new change record or update the change record with the new value. This is used by attribute change tracking.
 */
public void updateChangeRecord(Object sourceClone,Object newValue,Object oldValue,ObjectChangeSet objectChangeSet,UnitOfWorkImpl uow) throws DescriptorException {
  AggregateChangeRecord changeRecord=(AggregateChangeRecord)objectChangeSet.getChangesForAttributeNamed(this.getAttributeName());
  if (changeRecord == null) {
    changeRecord=new AggregateChangeRecord(objectChangeSet);
    changeRecord.setAttribute(this.getAttributeName());
    changeRecord.setMapping(this);
    objectChangeSet.addChange(changeRecord);
  }
  if (sourceClone.getClass().equals(objectChangeSet.getClassType(uow))) {
    ClassDescriptor referenceDescriptor=getReferenceDescriptor(newValue,uow);
    if (newValue == null) {
      changeRecord.setChangedObject(null);
      if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
        ((AggregateAttributeChangeListener)((ChangeTracker)oldValue)._persistence_getPropertyChangeListener()).setParentListener(null);
      }
      return;
    }
 else {
      UnitOfWorkChangeSet uowChangeSet=(UnitOfWorkChangeSet)objectChangeSet.getUOWChangeSet();
      ObjectChangeSet aggregateChangeSet=(ObjectChangeSet)uowChangeSet.getObjectChangeSetForClone(newValue);
      if (aggregateChangeSet != null) {
        aggregateChangeSet.clear();
      }
      if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
        if (oldValue != null) {
          ((AggregateAttributeChangeListener)((ChangeTracker)oldValue)._persistence_getPropertyChangeListener()).setParentListener(null);
        }
        AggregateAttributeChangeListener newListener=(AggregateAttributeChangeListener)((ChangeTracker)newValue)._persistence_getPropertyChangeListener();
        if (newListener == null) {
          newListener=new AggregateAttributeChangeListener(referenceDescriptor,uow,((AttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener()),this.getAttributeName(),newValue);
          ((ChangeTracker)newValue)._persistence_setPropertyChangeListener(newListener);
        }
        newListener.setParentListener((AttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener());
      }
      changeRecord.setChangedObject(referenceDescriptor.getObjectChangePolicy().createObjectChangeSetThroughComparison(newValue,oldValue,uowChangeSet,(oldValue == null),uow,referenceDescriptor));
      referenceDescriptor.getObjectChangePolicy().setChangeSetOnListener((ObjectChangeSet)changeRecord.getChangedObject(),newValue);
    }
  }
 else {
    if (referenceDescriptor.getObjectChangePolicy().isAttributeChangeTrackingPolicy()) {
      changeRecord.setChangedObject(((AggregateAttributeChangeListener)((ChangeTracker)sourceClone)._persistence_getPropertyChangeListener()).getObjectChangeSet());
    }
 else {
      changeRecord.setChangedObject(referenceDescriptor.getObjectChangePolicy().createObjectChangeSetThroughComparison(sourceClone,null,(UnitOfWorkChangeSet)objectChangeSet.getUOWChangeSet(),true,uow,referenceDescriptor));
    }
  }
}