Program: 63977
Project: 63977
Buggy source:
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  try {
    Descriptor xmlDescriptor=(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
    if (xmlDescriptor == null) {
      xmlDescriptor=findReferenceDescriptor(xPathFragment,unmarshalRecord,atts,xmlCompositeCollectionMapping,xmlCompositeCollectionMapping.getKeepAsElementPolicy());
      if (xmlDescriptor == null) {
        if (unmarshalRecord.getXMLReader().isNullRepresentedByXsiNil(xmlCompositeCollectionMapping.getNullPolicy())) {
          if (unmarshalRecord.isNil()) {
            return true;
          }
        }
 else         if (xmlCompositeCollectionMapping.getNullPolicy().valueIsNull(atts)) {
          getContainerPolicy().addInto(null,unmarshalRecord.getContainerInstance(this),unmarshalRecord.getSession());
          return true;
        }
        if (xmlCompositeCollectionMapping.getField() != null) {
          QName leafType=((Field)xmlCompositeCollectionMapping.getField()).getLastXPathFragment().getLeafElementType();
          if (leafType != null) {
            XPathFragment frag=new XPathFragment();
            frag.setNamespaceAware(unmarshalRecord.isNamespaceAware());
            String xpath=leafType.getLocalPart();
            String uri=leafType.getNamespaceURI();
            if (uri != null && uri.length() > 0) {
              frag.setNamespaceURI(uri);
              String prefix=((Descriptor)xmlCompositeCollectionMapping.getDescriptor()).getNonNullNamespaceResolver().resolveNamespaceURI(uri);
              if (prefix != null && prefix.length() > 0) {
                xpath=prefix + Constants.COLON + xpath;
              }
            }
            frag.setXPath(xpath);
            Context xmlContext=unmarshalRecord.getUnmarshaller().getContext();
            xmlDescriptor=xmlContext.getDescriptorByGlobalType(frag);
          }
        }
      }
      UnmarshalKeepAsElementPolicy policy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
      if (policy != null && ((xmlDescriptor == null && policy.isKeepUnknownAsElement()) || policy.isKeepAllAsElement())) {
        if (unmarshalRecord.getTypeQName() != null) {
          Class theClass=(Class)((XMLConversionManager)unmarshalRecord.getSession().getDatasourcePlatform().getConversionManager()).getDefaultXMLTypes().get(unmarshalRecord.getTypeQName());
          if (theClass == null) {
            setupHandlerForKeepAsElementPolicy(unmarshalRecord,xPathFragment,atts);
            return true;
          }
        }
 else {
          setupHandlerForKeepAsElementPolicy(unmarshalRecord,xPathFragment,atts);
          return true;
        }
      }
    }
    AbstractNullPolicy nullPolicy=xmlCompositeCollectionMapping.getNullPolicy();
    if (nullPolicy.isNullRepresentedByEmptyNode()) {
      String qnameString=xPathFragment.getLocalName();
      if (xPathFragment.getPrefix() != null) {
        qnameString=xPathFragment.getPrefix() + Constants.COLON + qnameString;
      }
      if (null != xmlDescriptor) {
        CompositeCollectionMappingContentHandler aHandler=new CompositeCollectionMappingContentHandler(unmarshalRecord,this,xmlCompositeCollectionMapping,atts,xPathFragment,xmlDescriptor);
        aHandler.startElement(xPathFragment.getNamespaceURI(),xPathFragment.getLocalName(),qnameString,atts);
        XMLReader xmlReader=unmarshalRecord.getXMLReader();
        xmlReader.setContentHandler(aHandler);
        xmlReader.setLexicalHandler(aHandler);
      }
    }
 else     if (!(unmarshalRecord.getXMLReader().isNullRepresentedByXsiNil(nullPolicy) && unmarshalRecord.isNil())) {
      Field xmlFld=(Field)this.xmlCompositeCollectionMapping.getField();
      if (xmlFld.hasLastXPathFragment()) {
        unmarshalRecord.setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType());
      }
      processChild(xPathFragment,unmarshalRecord,atts,xmlDescriptor,xmlCompositeCollectionMapping);
    }
  }
 catch (  SAXException e) {
    throw XMLMarshalException.unmarshalException(e);
  }
  return true;
}

Fixed version (ground truth):
public boolean startElement(XPathFragment xPathFragment,UnmarshalRecord unmarshalRecord,Attributes atts){
  try {
    Descriptor xmlDescriptor=(Descriptor)xmlCompositeCollectionMapping.getReferenceDescriptor();
    if (xmlDescriptor == null) {
      xmlDescriptor=findReferenceDescriptor(xPathFragment,unmarshalRecord,atts,xmlCompositeCollectionMapping,xmlCompositeCollectionMapping.getKeepAsElementPolicy());
      if (xmlDescriptor == null) {
        if (unmarshalRecord.getXMLReader().isNullRepresentedByXsiNil(xmlCompositeCollectionMapping.getNullPolicy())) {
          if (unmarshalRecord.isNil()) {
            return true;
          }
        }
 else         if (xmlCompositeCollectionMapping.getNullPolicy().valueIsNull(atts)) {
          getContainerPolicy().addInto(null,unmarshalRecord.getContainerInstance(this),unmarshalRecord.getSession());
          return true;
        }
        if (xmlCompositeCollectionMapping.getField() != null) {
          QName leafType=((Field)xmlCompositeCollectionMapping.getField()).getLastXPathFragment().getLeafElementType();
          if (leafType != null) {
            XPathFragment frag=new XPathFragment();
            frag.setNamespaceAware(unmarshalRecord.isNamespaceAware());
            String xpath=leafType.getLocalPart();
            String uri=leafType.getNamespaceURI();
            if (uri != null && uri.length() > 0) {
              frag.setNamespaceURI(uri);
              String prefix=((Descriptor)xmlCompositeCollectionMapping.getDescriptor()).getNonNullNamespaceResolver().resolveNamespaceURI(uri);
              if (prefix != null && prefix.length() > 0) {
                xpath=prefix + Constants.COLON + xpath;
              }
            }
            frag.setXPath(xpath);
            Context xmlContext=unmarshalRecord.getUnmarshaller().getContext();
            xmlDescriptor=xmlContext.getDescriptorByGlobalType(frag);
          }
        }
      }
      UnmarshalKeepAsElementPolicy policy=xmlCompositeCollectionMapping.getKeepAsElementPolicy();
      if (policy != null && ((xmlDescriptor == null && policy.isKeepUnknownAsElement()) || policy.isKeepAllAsElement())) {
        if (unmarshalRecord.getTypeQName() != null) {
          Class theClass=(Class)XMLConversionManager.getDefaultXMLTypes().get(unmarshalRecord.getTypeQName());
          if (theClass == null) {
            setupHandlerForKeepAsElementPolicy(unmarshalRecord,xPathFragment,atts);
            return true;
          }
        }
 else {
          setupHandlerForKeepAsElementPolicy(unmarshalRecord,xPathFragment,atts);
          return true;
        }
      }
    }
    AbstractNullPolicy nullPolicy=xmlCompositeCollectionMapping.getNullPolicy();
    if (nullPolicy.isNullRepresentedByEmptyNode()) {
      String qnameString=xPathFragment.getLocalName();
      if (xPathFragment.getPrefix() != null) {
        qnameString=xPathFragment.getPrefix() + Constants.COLON + qnameString;
      }
      if (null != xmlDescriptor) {
        CompositeCollectionMappingContentHandler aHandler=new CompositeCollectionMappingContentHandler(unmarshalRecord,this,xmlCompositeCollectionMapping,atts,xPathFragment,xmlDescriptor);
        aHandler.startElement(xPathFragment.getNamespaceURI(),xPathFragment.getLocalName(),qnameString,atts);
        XMLReader xmlReader=unmarshalRecord.getXMLReader();
        xmlReader.setContentHandler(aHandler);
        xmlReader.setLexicalHandler(aHandler);
      }
    }
 else     if (!(unmarshalRecord.getXMLReader().isNullRepresentedByXsiNil(nullPolicy) && unmarshalRecord.isNil())) {
      Field xmlFld=(Field)this.xmlCompositeCollectionMapping.getField();
      if (xmlFld.hasLastXPathFragment()) {
        unmarshalRecord.setLeafElementType(xmlFld.getLastXPathFragment().getLeafElementType());
      }
      processChild(xPathFragment,unmarshalRecord,atts,xmlDescriptor,xmlCompositeCollectionMapping);
    }
  }
 catch (  SAXException e) {
    throw XMLMarshalException.unmarshalException(e);
  }
  return true;
}