Program: 67327
Project: 67327
Buggy source:
/** 
 * INTERNAL: Clones the descriptor
 */
public Object clone(){
  ClassDescriptor clonedDescriptor=null;
  try {
    clonedDescriptor=(ClassDescriptor)super.clone();
  }
 catch (  Exception 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 queryKeyVector=new HashMap(getQueryKeys().size() + 2);
  for (Iterator queryKeysEnum=getQueryKeys().values().iterator(); queryKeysEnum.hasNext(); ) {
    QueryKey queryKey=(QueryKey)((QueryKey)queryKeysEnum.next()).clone();
    queryKey.setDescriptor(clonedDescriptor);
    queryKeyVector.put(queryKey.getName(),queryKey);
  }
  clonedDescriptor.setQueryKeys(queryKeyVector);
  List primaryKeyVector=new ArrayList(getPrimaryKeyFields().size());
  List primaryKeyFields=getPrimaryKeyFields();
  for (int index=0; index < primaryKeyFields.size(); index++) {
    DatabaseField primaryKey=(DatabaseField)((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.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());
  }
  clonedDescriptor.setIsIsolated(isIsolated());
  clonedDescriptor.setInstantiationPolicy((InstantiationPolicy)getInstantiationPolicy().clone());
  clonedDescriptor.setCopyPolicy((CopyPolicy)getCopyPolicy().clone());
  if (getOptimisticLockingPolicy() != null) {
    clonedDescriptor.setOptimisticLockingPolicy((OptimisticLockingPolicy)getOptimisticLockingPolicy().clone());
  }
  clonedDescriptor.setObjectChangePolicy(this.getObjectChangePolicyInternal());
  return clonedDescriptor;
}

Fixed version (ground truth):
/** 
 * INTERNAL: Clones the descriptor
 */
public Object clone(){
  ClassDescriptor clonedDescriptor=null;
  try {
    clonedDescriptor=(ClassDescriptor)super.clone();
  }
 catch (  Exception 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 queryKeyVector=new HashMap(getQueryKeys().size() + 2);
  for (Iterator queryKeysEnum=getQueryKeys().values().iterator(); queryKeysEnum.hasNext(); ) {
    QueryKey queryKey=(QueryKey)((QueryKey)queryKeysEnum.next()).clone();
    queryKey.setDescriptor(clonedDescriptor);
    queryKeyVector.put(queryKey.getName(),queryKey);
  }
  clonedDescriptor.setQueryKeys(queryKeyVector);
  List primaryKeyVector=new ArrayList(getPrimaryKeyFields().size());
  List primaryKeyFields=getPrimaryKeyFields();
  for (int index=0; index < primaryKeyFields.size(); index++) {
    DatabaseField primaryKey=(DatabaseField)((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.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());
  }
  clonedDescriptor.setIsIsolated(isIsolated());
  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());
  return clonedDescriptor;
}