Program: 63346
Project: 63346
Buggy source:
/** 
 * INTERNAL: Clones the descriptor
 */
public Object clone(){
  ClassDescriptor clonedDescriptor=null;
  try {
    clonedDescriptor=(ClassDescriptor)super.clone();
  }
 catch (  Exception exception) {
    throw new AssertionError(exception);
  }
  Vector mappingsVector=NonSynchronizedVector.newInstance();
  for (Enumeration mappingsEnum=getMappings().elements(); mappingsEnum.hasMoreElements(); ) {
    DatabaseMapping mapping;
    mapping=(DatabaseMapping)((DatabaseMapping)mappingsEnum.nextElement()).clone();
    mapping.setDescriptor(clonedDescriptor);
    mappingsVector.addElement(mapping);
  }
  clonedDescriptor.setMappings(mappingsVector);
  Map queryKeys=new HashMap(getQueryKeys().size() + 2);
  for (  QueryKey queryKey : getQueryKeys().values()) {
    queryKey=(QueryKey)queryKey.clone();
    queryKey.setDescriptor(clonedDescriptor);
    queryKeys.put(queryKey.getName(),queryKey);
  }
  clonedDescriptor.setQueryKeys(queryKeys);
  List primaryKeyVector=new ArrayList(getPrimaryKeyFields().size());
  List primaryKeyFields=getPrimaryKeyFields();
  for (int index=0; index < primaryKeyFields.size(); index++) {
    DatabaseField primaryKey=((DatabaseField)primaryKeyFields.get(index)).clone();
    primaryKeyVector.add(primaryKey);
  }
  clonedDescriptor.setPrimaryKeyFields(primaryKeyVector);
  clonedDescriptor.setFields(NonSynchronizedVector.newInstance());
  if (clonedDescriptor.hasInheritance()) {
    clonedDescriptor.setInheritancePolicy((InheritancePolicy)getInheritancePolicy().clone());
    clonedDescriptor.getInheritancePolicy().setDescriptor(clonedDescriptor);
  }
  if (clonedDescriptor.hasSerializedObjectPolicy()) {
    clonedDescriptor.setSerializedObjectPolicy(getSerializedObjectPolicy().clone());
  }
  if (clonedDescriptor.hasReturningPolicy()) {
    clonedDescriptor.setReturningPolicy((ReturningPolicy)getReturningPolicy().clone());
    clonedDescriptor.getReturningPolicy().setDescriptor(clonedDescriptor);
  }
  clonedDescriptor.setObjectBuilder((ObjectBuilder)getObjectBuilder().clone());
  clonedDescriptor.getObjectBuilder().setDescriptor(clonedDescriptor);
  clonedDescriptor.setEventManager((DescriptorEventManager)getEventManager().clone());
  clonedDescriptor.getEventManager().setDescriptor(clonedDescriptor);
  clonedDescriptor.setQueryManager((DescriptorQueryManager)getQueryManager().clone());
  clonedDescriptor.getQueryManager().setDescriptor(clonedDescriptor);
  if (hasFetchGroupManager()) {
    clonedDescriptor.setFetchGroupManager((FetchGroupManager)getFetchGroupManager().clone());
  }
  if (this.cachePolicy != null) {
    clonedDescriptor.setCachePolicy(this.cachePolicy.clone());
  }
  if (this.instantiationPolicy != null) {
    clonedDescriptor.setInstantiationPolicy((InstantiationPolicy)getInstantiationPolicy().clone());
  }
  if (this.copyPolicy != null) {
    clonedDescriptor.setCopyPolicy((CopyPolicy)getCopyPolicy().clone());
  }
  if (getOptimisticLockingPolicy() != null) {
    clonedDescriptor.setOptimisticLockingPolicy((OptimisticLockingPolicy)getOptimisticLockingPolicy().clone());
  }
  clonedDescriptor.setObjectChangePolicy(this.getObjectChangePolicyInternal());
  Vector<DatabaseTable> tables=NonSynchronizedVector.newInstance(3);
  for (  DatabaseTable table : getTables()) {
    tables.add(table.clone());
  }
  clonedDescriptor.setTables(tables);
  if (getDefaultTable() != null) {
    clonedDescriptor.setDefaultTable(getDefaultTable().clone());
  }
  if (getCMPPolicy() != null) {
    clonedDescriptor.setCMPPolicy(getCMPPolicy().clone());
    clonedDescriptor.getCMPPolicy().setDescriptor(clonedDescriptor);
  }
  if (getSequenceNumberField() != null) {
    clonedDescriptor.setSequenceNumberField(getSequenceNumberField().clone());
  }
  if (hasMultitenantPolicy()) {
    clonedDescriptor.setMultitenantPolicy(getMultitenantPolicy().clone(clonedDescriptor));
  }
  return clonedDescriptor;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Clones the descriptor
 */
public Object clone(){
  ClassDescriptor clonedDescriptor=null;
  try {
    clonedDescriptor=(ClassDescriptor)super.clone();
  }
 catch (  Exception exception) {
    throw new AssertionError(exception);
  }
  Vector mappingsVector=NonSynchronizedVector.newInstance();
  for (Enumeration mappingsEnum=getMappings().elements(); mappingsEnum.hasMoreElements(); ) {
    DatabaseMapping mapping;
    mapping=(DatabaseMapping)((DatabaseMapping)mappingsEnum.nextElement()).clone();
    mapping.setDescriptor(clonedDescriptor);
    mappingsVector.addElement(mapping);
  }
  clonedDescriptor.setMappings(mappingsVector);
  Map queryKeys=new HashMap(getQueryKeys().size() + 2);
  for (  QueryKey queryKey : getQueryKeys().values()) {
    queryKey=(QueryKey)queryKey.clone();
    queryKey.setDescriptor(clonedDescriptor);
    queryKeys.put(queryKey.getName(),queryKey);
  }
  clonedDescriptor.setQueryKeys(queryKeys);
  List primaryKeyVector=new ArrayList(getPrimaryKeyFields().size());
  List primaryKeyFields=getPrimaryKeyFields();
  for (int index=0; index < primaryKeyFields.size(); index++) {
    DatabaseField primaryKey=((DatabaseField)primaryKeyFields.get(index)).clone();
    primaryKeyVector.add(primaryKey);
  }
  clonedDescriptor.setPrimaryKeyFields(primaryKeyVector);
  clonedDescriptor.setFields(NonSynchronizedVector.newInstance());
  referencingClasses=new HashSet<>();
  if (this.mappingsPostCalculateChanges != null) {
    clonedDescriptor.mappingsPostCalculateChanges=new ArrayList<>();
    for (    DatabaseMapping databaseMapping : this.mappingsPostCalculateChanges) {
      clonedDescriptor.mappingsPostCalculateChanges.add((DatabaseMapping)databaseMapping.clone());
    }
  }
  if (this.mappingsPostCalculateChangesOnDeleted != null) {
    clonedDescriptor.mappingsPostCalculateChangesOnDeleted=new ArrayList<>();
    for (    DatabaseMapping databaseMapping : this.mappingsPostCalculateChangesOnDeleted) {
      clonedDescriptor.mappingsPostCalculateChangesOnDeleted.add((DatabaseMapping)databaseMapping.clone());
    }
  }
  if (clonedDescriptor.hasInheritance()) {
    clonedDescriptor.setInheritancePolicy((InheritancePolicy)getInheritancePolicy().clone());
    clonedDescriptor.getInheritancePolicy().setDescriptor(clonedDescriptor);
  }
  if (clonedDescriptor.hasSerializedObjectPolicy()) {
    clonedDescriptor.setSerializedObjectPolicy(getSerializedObjectPolicy().clone());
  }
  if (clonedDescriptor.hasReturningPolicy()) {
    clonedDescriptor.setReturningPolicy((ReturningPolicy)getReturningPolicy().clone());
    clonedDescriptor.getReturningPolicy().setDescriptor(clonedDescriptor);
  }
  clonedDescriptor.setObjectBuilder((ObjectBuilder)getObjectBuilder().clone());
  clonedDescriptor.getObjectBuilder().setDescriptor(clonedDescriptor);
  clonedDescriptor.setEventManager((DescriptorEventManager)getEventManager().clone());
  clonedDescriptor.getEventManager().setDescriptor(clonedDescriptor);
  clonedDescriptor.setQueryManager((DescriptorQueryManager)getQueryManager().clone());
  clonedDescriptor.getQueryManager().setDescriptor(clonedDescriptor);
  if (hasFetchGroupManager()) {
    clonedDescriptor.setFetchGroupManager((FetchGroupManager)getFetchGroupManager().clone());
  }
  if (this.cachePolicy != null) {
    clonedDescriptor.setCachePolicy(this.cachePolicy.clone());
  }
  if (this.instantiationPolicy != null) {
    clonedDescriptor.setInstantiationPolicy((InstantiationPolicy)getInstantiationPolicy().clone());
  }
  if (this.copyPolicy != null) {
    clonedDescriptor.setCopyPolicy((CopyPolicy)getCopyPolicy().clone());
  }
  if (getOptimisticLockingPolicy() != null) {
    clonedDescriptor.setOptimisticLockingPolicy((OptimisticLockingPolicy)getOptimisticLockingPolicy().clone());
  }
  clonedDescriptor.setObjectChangePolicy(this.getObjectChangePolicyInternal());
  Vector<DatabaseTable> tables=NonSynchronizedVector.newInstance(3);
  for (  DatabaseTable table : getTables()) {
    tables.add(table.clone());
  }
  clonedDescriptor.setTables(tables);
  if (getDefaultTable() != null) {
    clonedDescriptor.setDefaultTable(getDefaultTable().clone());
  }
  if (getCMPPolicy() != null) {
    clonedDescriptor.setCMPPolicy(getCMPPolicy().clone());
    clonedDescriptor.getCMPPolicy().setDescriptor(clonedDescriptor);
  }
  if (getSequenceNumberField() != null) {
    clonedDescriptor.setSequenceNumberField(getSequenceNumberField().clone());
  }
  if (hasMultitenantPolicy()) {
    clonedDescriptor.setMultitenantPolicy(getMultitenantPolicy().clone(clonedDescriptor));
  }
  return clonedDescriptor;
}