Program: 66053
Project: 66053
Buggy source:
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    if (null != selfRecords) {
      for (int x=0, selfRecordsSize=selfRecords.size(); x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=selfRecords.get(x);
        if (selfRecord != null) {
          selfRecord.endElement(namespaceURI,localName,qName);
        }
 else {
          getFragmentBuilder().endSelfElement(namespaceURI,localName,qName);
        }
      }
    }
    if (null != xPathNode.getUnmarshalNodeValue()) {
      xPathNode.getUnmarshalNodeValue().endElement(xPathFragment,this);
    }
 else {
      XPathNode textNode=xPathNode.getTextNode();
      if (null != textNode && textNode.isWhitespaceAware() && getStringBuffer().length() == 0) {
        NodeValue textNodeUnmarshalNodeValue=textNode.getUnmarshalNodeValue();
        if (!isXsiNil) {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            textNodeUnmarshalNodeValue.endElement(xPathFragment,this);
          }
        }
 else {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            DatabaseMapping mapping=((MappingNodeValue)textNodeUnmarshalNodeValue).getMapping();
            if (mapping.isAbstractDirectMapping()) {
              Object nullValue=((AbstractDirectMapping)mapping).getNullValue();
              if (!(XMLConstants.EMPTY_STRING.equals(nullValue))) {
                setAttributeValue(null,mapping);
                this.removeNullCapableValue((NullCapableValue)textNodeUnmarshalNodeValue);
              }
            }
            isXsiNil=false;
          }
        }
      }
    }
    XPathFragment xPathFragment=xPathNode.getXPathFragment();
    if (null != xPathFragment && xPathFragment.nameIsText()) {
      xPathNode=xPathNode.getParent();
    }
    if (null != xPathNode.getParent()) {
      xPathNode=xPathNode.getParent();
    }
    xpathNodeIsMixedContent=false;
    unmarshalContext.endElement(this);
    typeQName=null;
    levelIndex--;
    if ((0 == levelIndex) && (null != getParentRecord()) && !isSelfRecord()) {
      endDocument();
      UnmarshalRecord pRec=getParentRecord();
      while (pRec.isSelfRecord()) {
        pRec=pRec.getParentRecord();
      }
      pRec.endElement(namespaceURI,localName,qName);
      xmlReader.setContentHandler(pRec);
      xmlReader.setLexicalHandler(pRec);
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(null,null,null,0,0,e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}

Fixed version (ground truth):
public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  try {
    if (null != selfRecords) {
      for (int x=0, selfRecordsSize=selfRecords.size(); x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=selfRecords.get(x);
        if (selfRecord != null) {
          selfRecord.endElement(namespaceURI,localName,qName);
        }
 else {
          getFragmentBuilder().endSelfElement(namespaceURI,localName,qName);
        }
      }
    }
    if (-1 != unmappedLevel && unmappedLevel <= levelIndex) {
      if (levelIndex == unmappedLevel) {
        unmappedLevel=-1;
      }
      levelIndex--;
      return;
    }
    if (null != xPathNode.getUnmarshalNodeValue()) {
      xPathNode.getUnmarshalNodeValue().endElement(xPathFragment,this);
    }
 else {
      XPathNode textNode=xPathNode.getTextNode();
      if (null != textNode && textNode.isWhitespaceAware() && getStringBuffer().length() == 0) {
        NodeValue textNodeUnmarshalNodeValue=textNode.getUnmarshalNodeValue();
        if (!isXsiNil) {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            textNodeUnmarshalNodeValue.endElement(xPathFragment,this);
          }
        }
 else {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            DatabaseMapping mapping=((MappingNodeValue)textNodeUnmarshalNodeValue).getMapping();
            if (mapping.isAbstractDirectMapping()) {
              Object nullValue=((AbstractDirectMapping)mapping).getNullValue();
              if (!(XMLConstants.EMPTY_STRING.equals(nullValue))) {
                setAttributeValue(null,mapping);
                this.removeNullCapableValue((NullCapableValue)textNodeUnmarshalNodeValue);
              }
            }
            isXsiNil=false;
          }
        }
      }
    }
    XPathFragment xPathFragment=xPathNode.getXPathFragment();
    if (null != xPathFragment && xPathFragment.nameIsText()) {
      xPathNode=xPathNode.getParent();
    }
    if (null != xPathNode.getParent()) {
      xPathNode=xPathNode.getParent();
    }
    xpathNodeIsMixedContent=false;
    unmarshalContext.endElement(this);
    typeQName=null;
    levelIndex--;
    if ((0 == levelIndex) && (null != getParentRecord()) && !isSelfRecord()) {
      endDocument();
      UnmarshalRecord pRec=getParentRecord();
      while (pRec.isSelfRecord()) {
        pRec=pRec.getParentRecord();
      }
      pRec.endElement(namespaceURI,localName,qName);
      xmlReader.setContentHandler(pRec);
      xmlReader.setLexicalHandler(pRec);
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(null,null,null,0,0,e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}