Program: 65540
Project: 65540
Buggy source:
public void initialize(AbstractSession session) throws DescriptorException {
  mappingsByField.clear();
  if (null != readOnlyMappingsByField) {
    readOnlyMappingsByField.clear();
  }
  if (null != mappingsByAttribute) {
    mappingsByAttribute.clear();
  }
  cloningMappings.clear();
  if (null != eagerMappings) {
    eagerMappings.clear();
  }
  if (null != relationshipMappings) {
    relationshipMappings.clear();
  }
  for (Enumeration mappings=this.descriptor.getMappings().elements(); mappings.hasMoreElements(); ) {
    DatabaseMapping mapping=(DatabaseMapping)mappings.nextElement();
    if (!mapping.isWriteOnly()) {
      if (mappingsByAttribute != null) {
        getMappingsByAttribute().put(mapping.getAttributeName(),mapping);
      }
    }
    if (mapping.isCloningRequired()) {
      getCloningMappings().add(mapping);
    }
    if (mapping.isForeignReferenceMapping() && ((ForeignReferenceMapping)mapping).usesIndirection() && (!mapping.isLazy())) {
      getEagerMappings().add(mapping);
    }
    if (!mapping.isDirectToFieldMapping()) {
      if (null != relationshipMappings) {
        relationshipMappings.add(mapping);
      }
    }
    for (    DatabaseField field : mapping.getFields()) {
      if (mapping.isReadOnly()) {
        if (null != readOnlyMappingsByField) {
          List readOnlyMappings=getReadOnlyMappingsByField().get(field);
          if (readOnlyMappings == null) {
            readOnlyMappings=new ArrayList();
            getReadOnlyMappingsByField().put(field,readOnlyMappings);
          }
          readOnlyMappings.add(mapping);
        }
      }
 else {
        if (mapping.isAggregateObjectMapping()) {
          ObjectBuilder aggregateObjectBuilder=((AggregateObjectMapping)mapping).getReferenceDescriptor().getObjectBuilder();
          DatabaseMapping aggregatedFieldMapping=aggregateObjectBuilder.getMappingForField(field);
          if (aggregatedFieldMapping == null) {
            List readOnlyMappings=getReadOnlyMappingsByField().get(field);
            if (readOnlyMappings == null) {
              readOnlyMappings=new ArrayList();
              getReadOnlyMappingsByField().put(field,readOnlyMappings);
            }
            readOnlyMappings.add(mapping);
          }
 else {
            getMappingsByField().put(field,mapping);
          }
        }
 else {
          if (!getMappingsByField().containsKey(field)) {
            getMappingsByField().put(field,mapping);
          }
        }
      }
    }
  }
  this.isSimple=null == relationshipMappings || relationshipMappings.isEmpty();
  initializePrimaryKey(session);
  initializeJoinedAttributes();
  if (this.descriptor.usesSequenceNumbers()) {
    DatabaseMapping sequenceMapping=getMappingForField(this.descriptor.getSequenceNumberField());
    if ((sequenceMapping != null) && sequenceMapping.isDirectToFieldMapping()) {
      setSequenceMapping((AbstractDirectMapping)sequenceMapping);
    }
  }
}

Fixed version (ground truth):
public void initialize(AbstractSession session) throws DescriptorException {
  mappingsByField.clear();
  if (null != readOnlyMappingsByField) {
    readOnlyMappingsByField.clear();
  }
  if (null != mappingsByAttribute) {
    mappingsByAttribute.clear();
  }
  cloningMappings.clear();
  if (null != eagerMappings) {
    eagerMappings.clear();
  }
  if (null != relationshipMappings) {
    relationshipMappings.clear();
  }
  for (Enumeration mappings=this.descriptor.getMappings().elements(); mappings.hasMoreElements(); ) {
    DatabaseMapping mapping=(DatabaseMapping)mappings.nextElement();
    if (!mapping.isWriteOnly()) {
      if (mappingsByAttribute != null) {
        getMappingsByAttribute().put(mapping.getAttributeName(),mapping);
      }
    }
    if (mapping.isCloningRequired()) {
      getCloningMappings().add(mapping);
    }
    if (mapping.isForeignReferenceMapping() && ((ForeignReferenceMapping)mapping).usesIndirection() && (!mapping.isLazy())) {
      getEagerMappings().add(mapping);
    }
    if (!mapping.isDirectToFieldMapping()) {
      if (null != relationshipMappings) {
        relationshipMappings.add(mapping);
      }
    }
    for (    DatabaseField field : mapping.getFields()) {
      if (mapping.isReadOnly()) {
        if (null != readOnlyMappingsByField) {
          List readOnlyMappings=getReadOnlyMappingsByField().get(field);
          if (readOnlyMappings == null) {
            readOnlyMappings=new ArrayList();
            getReadOnlyMappingsByField().put(field,readOnlyMappings);
          }
          readOnlyMappings.add(mapping);
        }
      }
 else {
        if (mapping.isAggregateObjectMapping()) {
          ObjectBuilder aggregateObjectBuilder=((AggregateObjectMapping)mapping).getReferenceDescriptor().getObjectBuilder();
          DatabaseMapping aggregatedFieldMapping=aggregateObjectBuilder.getMappingForField(field);
          if (aggregatedFieldMapping == null) {
            List readOnlyMappings=getReadOnlyMappingsByField().get(field);
            if (readOnlyMappings == null) {
              readOnlyMappings=new ArrayList();
              getReadOnlyMappingsByField().put(field,readOnlyMappings);
            }
            readOnlyMappings.add(mapping);
          }
 else {
            getMappingsByField().put(field,mapping);
          }
        }
 else {
          if (!getMappingsByField().containsKey(field)) {
            getMappingsByField().put(field,mapping);
          }
        }
      }
    }
  }
  this.isSimple=null == relationshipMappings || relationshipMappings.isEmpty();
  initializePrimaryKey(session);
  initializeJoinedAttributes();
  if (this.descriptor.usesSequenceNumbers()) {
    DatabaseMapping sequenceMapping=getMappingForField(this.descriptor.getSequenceNumberField());
    if ((sequenceMapping != null) && sequenceMapping.isDirectToFieldMapping()) {
      setSequenceMapping((AbstractDirectMapping)sequenceMapping);
    }
  }
  if (descriptor.hasInheritance()) {
    XMLField indicatorField=(XMLField)descriptor.getInheritancePolicy().getClassIndicatorField();
    if (indicatorField != null) {
      if (indicatorField.getLastXPathFragment().getNamespaceURI() != null && indicatorField.getLastXPathFragment().getNamespaceURI().equals(XMLConstants.SCHEMA_INSTANCE_URL) && indicatorField.getLastXPathFragment().getLocalName().equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
        xsiTypeIndicatorField=true;
      }
    }
  }
}