Program: 64799
Project: 64799
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 (-1 != unmappedLevel && unmappedLevel <= levelIndex) {
      if (levelIndex == unmappedLevel) {
        unmappedLevel=-1;
      }
      levelIndex--;
      return;
    }
    NodeValue unmarshalNodeValue=xPathNode.getUnmarshalNodeValue();
    if (null != unmarshalNodeValue) {
      try {
        unmarshalNodeValue.endElement(xPathFragment,this);
      }
 catch (      EclipseLinkException e) {
        if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
          throw e;
        }
 else {
          SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),documentLocator,e);
          xmlReader.getErrorHandler().warning(saxParseException);
        }
      }
    }
 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()) || (xpathNodeIsMixedContent && xPathNode.getParent() != null)) {
      xPathNode=xPathNode.getParent();
    }
    if (null != xPathNode.getParent()) {
      xPathNode=xPathNode.getParent();
    }
    xpathNodeIsMixedContent=false;
    unmarshalContext.endElement(this);
    typeQName=null;
    levelIndex--;
    if (this.isNil() && levelIndex > 0) {
      this.setNil(false);
    }
    if ((0 == levelIndex) && (null != parentRecord) && !isSelfRecord()) {
      endDocument();
      UnmarshalRecord pRec=parentRecord;
      while (pRec.isSelfRecord()) {
        pRec=pRec.parentRecord;
      }
      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().warning(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;
    }
    NodeValue unmarshalNodeValue=xPathNode.getUnmarshalNodeValue();
    if (null != unmarshalNodeValue) {
      try {
        unmarshalNodeValue.endElement(xPathFragment,this);
      }
 catch (      EclipseLinkException e) {
        if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
          throw e;
        }
 else {
          SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),getDocumentLocator(),e);
          xmlReader.getErrorHandler().warning(saxParseException);
        }
      }
    }
 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()) || (xpathNodeIsMixedContent && xPathNode.getParent() != null)) {
      xPathNode=xPathNode.getParent();
    }
    if (null != xPathNode.getParent()) {
      xPathNode=xPathNode.getParent();
    }
    xpathNodeIsMixedContent=false;
    unmarshalContext.endElement(this);
    typeQName=null;
    levelIndex--;
    if (this.isNil() && levelIndex > 0) {
      this.setNil(false);
    }
    if ((0 == levelIndex) && (null != parentRecord) && !isSelfRecord()) {
      endDocument();
      UnmarshalRecord pRec=parentRecord;
      while (pRec.isSelfRecord()) {
        pRec=pRec.parentRecord;
      }
      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().warning(saxParseException);
    }
  }
}