Program: 65845
Project: 65845
Buggy source:
@Override public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  XMLField field=null;
  Object value=this.getCharacters();
  Class attributeClassification=null;
  boolean isSwaRef=false;
  if (isCollection) {
    isSwaRef=((XMLBinaryDataCollectionMapping)mapping).isSwaRef();
    field=(XMLField)((XMLBinaryDataCollectionMapping)mapping).getField();
    attributeClassification=((XMLBinaryDataCollectionMapping)mapping).getAttributeElementClass();
  }
 else {
    isSwaRef=((XMLBinaryDataMapping)mapping).isSwaRef();
    field=(XMLField)((XMLBinaryDataMapping)mapping).getField();
    attributeClassification=((XMLBinaryDataMapping)mapping).getAttributeClassification();
  }
  if (isSwaRef && (parent.getUnmarshaller().getAttachmentUnmarshaller() != null)) {
    if (attributeClassification != null && attributeClassification == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) {
      value=parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsDataHandler(value.toString());
    }
 else {
      value=parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsByteArray(value.toString());
    }
    if (converter != null) {
      if (converter instanceof XMLConverter) {
        value=((XMLConverter)converter).convertDataValueToObjectValue(value,parent.getSession(),parent.getUnmarshaller());
      }
 else {
        value=converter.convertDataValueToObjectValue(value,parent.getSession());
      }
    }
  }
 else {
    Object valueFromReader=this.parent.getXMLReader().getValue(this.characters,attributeClassification);
    if (null != valueFromReader) {
      value=valueFromReader;
    }
 else {
      value=XMLConversionManager.getDefaultXMLManager().convertSchemaBase64ToByteArray(value.toString());
    }
    value=XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(value,attributeClassification,parent.getSession());
  }
  if (converter != null) {
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertDataValueToObjectValue(value,parent.getSession(),parent.getUnmarshaller());
    }
 else {
      value=converter.convertDataValueToObjectValue(value,parent.getSession());
    }
  }
  if (isCollection) {
    if (value != null) {
      parent.addAttributeValue((ContainerValue)nodeValue,value);
    }
  }
 else {
    parent.setAttributeValue(value,mapping);
  }
  if (!field.isSelfField()) {
    parent.getXMLReader().setContentHandler(parent);
    parent.endElement(namespaceURI,localName,qName);
  }
  resetStringBuffer();
}

Fixed version (ground truth):
@Override public void endElement(String namespaceURI,String localName,String qName) throws SAXException {
  XMLField field=null;
  Object value=this.getCharacters();
  Class attributeClassification=null;
  boolean isSwaRef=false;
  if (isCollection) {
    isSwaRef=((XMLBinaryDataCollectionMapping)mapping).isSwaRef();
    field=(XMLField)((XMLBinaryDataCollectionMapping)mapping).getField();
    attributeClassification=((XMLBinaryDataCollectionMapping)mapping).getAttributeElementClass();
  }
 else {
    isSwaRef=((XMLBinaryDataMapping)mapping).isSwaRef();
    field=(XMLField)((XMLBinaryDataMapping)mapping).getField();
    attributeClassification=((XMLBinaryDataMapping)mapping).getAttributeClassification();
  }
  if (isSwaRef && (parent.getUnmarshaller().getAttachmentUnmarshaller() != null)) {
    if (attributeClassification != null && attributeClassification == XMLBinaryDataHelper.getXMLBinaryDataHelper().DATA_HANDLER) {
      value=parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsDataHandler(value.toString());
    }
 else {
      value=parent.getUnmarshaller().getAttachmentUnmarshaller().getAttachmentAsByteArray(value.toString());
    }
    if (converter != null) {
      if (converter instanceof XMLConverter) {
        value=((XMLConverter)converter).convertDataValueToObjectValue(value,parent.getSession(),parent.getUnmarshaller());
      }
 else {
        value=converter.convertDataValueToObjectValue(value,parent.getSession());
      }
    }
  }
 else {
    Object valueFromReader=this.parent.getXMLReader().getValue(getCharacters(),attributeClassification);
    if (null != valueFromReader) {
      value=valueFromReader;
    }
 else {
      value=XMLConversionManager.getDefaultXMLManager().convertSchemaBase64ToByteArray(value.toString());
    }
    value=XMLBinaryDataHelper.getXMLBinaryDataHelper().convertObject(value,attributeClassification,parent.getSession());
  }
  if (converter != null) {
    if (converter instanceof XMLConverter) {
      value=((XMLConverter)converter).convertDataValueToObjectValue(value,parent.getSession(),parent.getUnmarshaller());
    }
 else {
      value=converter.convertDataValueToObjectValue(value,parent.getSession());
    }
  }
  if (isCollection) {
    if (value != null) {
      parent.addAttributeValue((ContainerValue)nodeValue,value);
    }
  }
 else {
    parent.setAttributeValue(value,mapping);
  }
  if (!field.isSelfField()) {
    parent.getXMLReader().setContentHandler(parent);
    parent.endElement(namespaceURI,localName,qName);
  }
  resetStringBuffer();
}