Program: 63574
Project: 63574
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) {
      boolean isIncludedInAttributeGroup=true;
      if (unmarshalNodeValue.isMappingNodeValue()) {
        Mapping mapping=((MappingNodeValue)unmarshalNodeValue).getMapping();
        isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
      }
      try {
        if (isIncludedInAttributeGroup) {
          unmarshalNodeValue.endElement(xPathFragment,this);
        }
 else {
          resetStringBuffer();
        }
      }
 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 (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
          Mapping mapping=((MappingNodeValue)textNodeUnmarshalNodeValue).getMapping();
          if (mapping.isAbstractDirectMapping() && isXsiNil) {
            Object nullValue=((DirectMapping)mapping).getNullValue();
            if (!(Constants.EMPTY_STRING.equals(nullValue))) {
              setAttributeValue(null,mapping);
              this.removeNullCapableValue((NullCapableValue)textNodeUnmarshalNodeValue);
            }
          }
 else {
            textNodeUnmarshalNodeValue.endElement(xPathFragment,this);
          }
          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.getParentRecord();
      }
      pRec.endElement(namespaceURI,localName,qName);
      xmlReader.setContentHandler(pRec);
      xmlReader.setLexicalHandler(pRec);
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      Locator locator=xmlReader.getLocator();
      SAXParseException saxParseException=new SAXParseException(null,getDocumentLocator(),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) {
      boolean isIncludedInAttributeGroup=true;
      if (unmarshalNodeValue.isMappingNodeValue()) {
        Mapping mapping=((MappingNodeValue)unmarshalNodeValue).getMapping();
        isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
      }
      try {
        if (isIncludedInAttributeGroup) {
          unmarshalNodeValue.endElement(xPathFragment,this);
        }
 else {
          resetStringBuffer();
        }
      }
 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 && getStringBuffer().length() == 0) {
        NodeValue textNodeUnmarshalNodeValue=textNode.getUnmarshalNodeValue();
        if (textNode.isWhitespaceAware()) {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            Mapping mapping=((MappingNodeValue)textNodeUnmarshalNodeValue).getMapping();
            if (mapping.isAbstractDirectMapping() && isXsiNil) {
              Object nullValue=((DirectMapping)mapping).getNullValue();
              if (!(Constants.EMPTY_STRING.equals(nullValue))) {
                setAttributeValue(null,mapping);
                this.removeNullCapableValue((NullCapableValue)textNodeUnmarshalNodeValue);
              }
            }
 else {
              textNodeUnmarshalNodeValue.endElement(xPathFragment,this);
            }
            isXsiNil=false;
          }
        }
 else {
          if (textNodeUnmarshalNodeValue.isMappingNodeValue()) {
            Mapping mapping=((MappingNodeValue)textNodeUnmarshalNodeValue).getMapping();
            if (mapping.isAbstractDirectMapping() && !isXsiNil && ((DirectMapping)mapping).getNullPolicy().isNullRepresentedByXsiNil()) {
              removeNullCapableValue((NullCapableValue)textNodeUnmarshalNodeValue);
            }
          }
        }
      }
    }
    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.getParentRecord();
      }
      pRec.endElement(namespaceURI,localName,qName);
      xmlReader.setContentHandler(pRec);
      xmlReader.setLexicalHandler(pRec);
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      Locator locator=xmlReader.getLocator();
      SAXParseException saxParseException=new SAXParseException(null,getDocumentLocator(),e);
      xmlReader.getErrorHandler().warning(saxParseException);
    }
  }
}