Program: 63667
Project: 63667
Buggy source:
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  if (currentObject == null) {
    initializeRecord(atts);
  }
  XPathFragment xPathNodeXPathFragment=xPathNode.getXPathFragment();
  if ((null != xPathNodeXPathFragment && xPathNodeXPathFragment.nameIsText()) || xpathNodeIsMixedContent) {
    xpathNodeIsMixedContent=false;
    NodeValue xPathNodeUnmarshalNodeValue=xPathNode.getUnmarshalNodeValue();
    if (null != xPathNodeUnmarshalNodeValue) {
      boolean isIncludedInAttributeGroup=true;
      if (xPathNodeUnmarshalNodeValue.isMappingNodeValue()) {
        Mapping mapping=((MappingNodeValue)xPathNodeUnmarshalNodeValue).getMapping();
        isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
      }
      if (isIncludedInAttributeGroup) {
        xPathNodeUnmarshalNodeValue.endElement(xPathFragment,this);
        if (xPathNode.getParent() != null) {
          xPathNode=xPathNode.getParent();
        }
      }
    }
  }
  if (null == rootElementName && null == rootElementLocalName && parentRecord == null) {
    rootElementLocalName=localName;
    rootElementName=qName;
    rootElementNamespaceUri=namespaceURI;
    schemaLocation=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_LOCATION);
    noNamespaceSchemaLocation=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.NO_NS_SCHEMA_LOCATION);
  }
  try {
    if (null != selfRecords) {
      for (int x=0, selfRecordsSize=selfRecords.size(); x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=selfRecords.get(x);
        if (selfRecord == null) {
          getFragmentBuilder().startElement(namespaceURI,localName,qName,atts);
        }
 else {
          selfRecord.startElement(namespaceURI,localName,qName,atts);
        }
      }
    }
    if (unmappedLevel != -1 && unmappedLevel <= levelIndex) {
      levelIndex++;
      return;
    }
    XPathNode node=getNonAttributeXPathNode(namespaceURI,localName,qName,atts);
    if (null == node && xPathNode.getTextNode() != null) {
      XPathFragment textWrapperFragment=getTextWrapperFragment();
      if (textWrapperFragment != null && localName.equals(textWrapperFragment.getLocalName())) {
        node=xPathNode.getTextNode();
      }
    }
    if (null == node) {
      NodeValue parentNodeValue=xPathNode.getUnmarshalNodeValue();
      if ((null == xPathNode.getXPathFragment()) && (parentNodeValue != null)) {
        XPathFragment parentFragment=new XPathFragment();
        parentFragment.setNamespaceAware(isNamespaceAware());
        if (namespaceURI != null && namespaceURI.length() == 0) {
          parentFragment.setLocalName(qName);
          parentFragment.setNamespaceURI(null);
        }
 else {
          parentFragment.setLocalName(localName);
          parentFragment.setNamespaceURI(namespaceURI);
        }
        if (parentNodeValue.startElement(parentFragment,this,atts)) {
          levelIndex++;
        }
 else {
          startUnmappedElement(namespaceURI,localName,qName,atts);
          return;
        }
      }
 else {
        levelIndex++;
        startUnmappedElement(namespaceURI,localName,qName,atts);
        return;
      }
    }
 else {
      xPathNode=node;
      unmarshalContext.startElement(this);
      levelIndex++;
      String xsiNilValue=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_NIL_ATTRIBUTE);
      if (xsiNilValue != null) {
        isXsiNil=xsiNilValue.equals(Constants.BOOLEAN_STRING_TRUE) || xsiNilValue.equals("String_Node_Str");
      }
      NodeValue nodeValue=node.getUnmarshalNodeValue();
      if (null != nodeValue) {
        boolean isIncludedInAttributeGroup=true;
        if (nodeValue.isMappingNodeValue()) {
          Mapping mapping=((MappingNodeValue)nodeValue).getMapping();
          isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
        }
        if (!isIncludedInAttributeGroup || !nodeValue.startElement(xPathFragment,this,atts)) {
          startUnmappedElement(namespaceURI,localName,qName,atts);
          return;
        }
      }
      if (xPathNode.getAttributeChildren() != null || xPathNode.getAnyAttributeNodeValue() != null || selfRecords != null) {
        for (int i=0, size=atts.getLength(); i < size; i++) {
          String attNamespace=atts.getURI(i);
          String attLocalName=atts.getLocalName(i);
          String value=atts.getValue(i);
          NodeValue attributeNodeValue=null;
          if ((attLocalName == null) || (attLocalName.length() == 0)) {
            String qname=atts.getQName(i);
            if (qname != null) {
              int qnameLength=qname.length();
              if (qnameLength > 0) {
                int idx=qname.indexOf(Constants.COLON);
                if (idx > 0) {
                  attLocalName=qname.substring(idx + 1,qnameLength);
                  String attPrefix=qname.substring(0,idx);
                  if (attPrefix.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
                    attNamespace=javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
                  }
                }
 else {
                  attLocalName=qname;
                  if (attLocalName.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
                    attNamespace=javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
                  }
                }
              }
            }
          }
          if (this.selfRecords != null) {
            for (int j=0; j < selfRecords.size(); j++) {
              UnmarshalRecord nestedRecord=selfRecords.get(j);
              if (nestedRecord != null) {
                attributeNodeValue=nestedRecord.getAttributeChildNodeValue(attNamespace,attLocalName);
                if (attributeNodeValue != null) {
                  attributeNodeValue.attribute(nestedRecord,attNamespace,attLocalName,value);
                }
              }
            }
          }
          if (attributeNodeValue == null) {
            attributeNodeValue=this.getAttributeChildNodeValue(attNamespace,attLocalName);
            try {
              if (attributeNodeValue != null) {
                if (attributeNodeValue.isMappingNodeValue()) {
                  Mapping mapping=((MappingNodeValue)attributeNodeValue).getMapping();
                  if (!unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName())) {
                    continue;
                  }
                }
                attributeNodeValue.attribute(this,attNamespace,attLocalName,value);
              }
 else {
                if (xPathNode.getAnyAttributeNodeValue() != null) {
                  xPathNode.getAnyAttributeNodeValue().attribute(this,attNamespace,attLocalName,value);
                }
              }
            }
 catch (            EclipseLinkException e) {
              if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
                throw e;
              }
 else {
                SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),getDocumentLocator(),e);
                xmlReader.getErrorHandler().warning(saxParseException);
              }
            }
          }
        }
      }
    }
    if (prefixesForFragment != null) {
      this.prefixesForFragment.clear();
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),getDocumentLocator(),e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}

Fixed version (ground truth):
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  if (currentObject == null) {
    initializeRecord(atts);
  }
  XPathFragment xPathNodeXPathFragment=xPathNode.getXPathFragment();
  if ((null != xPathNodeXPathFragment && xPathNodeXPathFragment.nameIsText()) || xpathNodeIsMixedContent) {
    xpathNodeIsMixedContent=false;
    NodeValue xPathNodeUnmarshalNodeValue=xPathNode.getUnmarshalNodeValue();
    if (null != xPathNodeUnmarshalNodeValue) {
      boolean isIncludedInAttributeGroup=true;
      if (xPathNodeUnmarshalNodeValue.isMappingNodeValue()) {
        Mapping mapping=((MappingNodeValue)xPathNodeUnmarshalNodeValue).getMapping();
        isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
      }
      if (isIncludedInAttributeGroup) {
        xPathNodeUnmarshalNodeValue.endElement(xPathFragment,this);
        if (xPathNode.getParent() != null) {
          xPathNode=xPathNode.getParent();
        }
      }
    }
  }
  if (null == rootElementName && null == rootElementLocalName && parentRecord == null) {
    rootElementLocalName=localName;
    rootElementName=qName;
    rootElementNamespaceUri=namespaceURI;
    schemaLocation=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_LOCATION);
    noNamespaceSchemaLocation=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.NO_NS_SCHEMA_LOCATION);
  }
  try {
    if (null != selfRecords) {
      for (int x=0, selfRecordsSize=selfRecords.size(); x < selfRecordsSize; x++) {
        UnmarshalRecord selfRecord=selfRecords.get(x);
        if (selfRecord == null) {
          getFragmentBuilder().startElement(namespaceURI,localName,qName,atts);
        }
 else {
          selfRecord.startElement(namespaceURI,localName,qName,atts);
        }
      }
    }
    if (unmappedLevel != -1 && unmappedLevel <= levelIndex) {
      levelIndex++;
      return;
    }
    XPathNode node=getNonAttributeXPathNode(namespaceURI,localName,qName,atts);
    if (null == node && xPathNode.getTextNode() != null) {
      XPathFragment textWrapperFragment=getTextWrapperFragment();
      if (textWrapperFragment != null && localName.equals(textWrapperFragment.getLocalName())) {
        node=xPathNode.getTextNode();
      }
    }
    if (null == node) {
      NodeValue parentNodeValue=xPathNode.getUnmarshalNodeValue();
      if ((null == xPathNode.getXPathFragment()) && (parentNodeValue != null)) {
        XPathFragment parentFragment=new XPathFragment();
        parentFragment.setNamespaceAware(isNamespaceAware());
        if (namespaceURI != null && namespaceURI.length() == 0) {
          parentFragment.setLocalName(qName);
          parentFragment.setNamespaceURI(null);
        }
 else {
          parentFragment.setLocalName(localName);
          parentFragment.setNamespaceURI(namespaceURI);
        }
        if (parentNodeValue.startElement(parentFragment,this,atts)) {
          levelIndex++;
        }
 else {
          startUnmappedElement(namespaceURI,localName,qName,atts);
          return;
        }
      }
 else {
        levelIndex++;
        startUnmappedElement(namespaceURI,localName,qName,atts);
        return;
      }
    }
 else {
      xPathNode=node;
      unmarshalContext.startElement(this);
      levelIndex++;
      String xsiNilValue=atts.getValue(javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,Constants.SCHEMA_NIL_ATTRIBUTE);
      if (xsiNilValue != null) {
        isXsiNil=xsiNilValue.equals(Constants.BOOLEAN_STRING_TRUE) || xsiNilValue.equals("String_Node_Str");
      }
      if (node.getNullCapableValue() != null) {
        getNullCapableValues().add(node.getNullCapableValue());
      }
      NodeValue nodeValue=node.getUnmarshalNodeValue();
      if (null != nodeValue) {
        boolean isIncludedInAttributeGroup=true;
        if (nodeValue.isMappingNodeValue()) {
          Mapping mapping=((MappingNodeValue)nodeValue).getMapping();
          isIncludedInAttributeGroup=this.unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName());
        }
        if (!isIncludedInAttributeGroup || !nodeValue.startElement(xPathFragment,this,atts)) {
          startUnmappedElement(namespaceURI,localName,qName,atts);
          return;
        }
      }
      if (xPathNode.getAttributeChildren() != null || xPathNode.getAnyAttributeNodeValue() != null || selfRecords != null) {
        for (int i=0, size=atts.getLength(); i < size; i++) {
          String attNamespace=atts.getURI(i);
          String attLocalName=atts.getLocalName(i);
          String value=atts.getValue(i);
          NodeValue attributeNodeValue=null;
          if ((attLocalName == null) || (attLocalName.length() == 0)) {
            String qname=atts.getQName(i);
            if (qname != null) {
              int qnameLength=qname.length();
              if (qnameLength > 0) {
                int idx=qname.indexOf(Constants.COLON);
                if (idx > 0) {
                  attLocalName=qname.substring(idx + 1,qnameLength);
                  String attPrefix=qname.substring(0,idx);
                  if (attPrefix.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
                    attNamespace=javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
                  }
                }
 else {
                  attLocalName=qname;
                  if (attLocalName.equals(javax.xml.XMLConstants.XMLNS_ATTRIBUTE)) {
                    attNamespace=javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
                  }
                }
              }
            }
          }
          if (this.selfRecords != null) {
            for (int j=0; j < selfRecords.size(); j++) {
              UnmarshalRecord nestedRecord=selfRecords.get(j);
              if (nestedRecord != null) {
                attributeNodeValue=nestedRecord.getAttributeChildNodeValue(attNamespace,attLocalName);
                if (attributeNodeValue != null) {
                  attributeNodeValue.attribute(nestedRecord,attNamespace,attLocalName,value);
                }
              }
            }
          }
          if (attributeNodeValue == null) {
            attributeNodeValue=this.getAttributeChildNodeValue(attNamespace,attLocalName);
            try {
              if (attributeNodeValue != null) {
                if (attributeNodeValue.isMappingNodeValue()) {
                  Mapping mapping=((MappingNodeValue)attributeNodeValue).getMapping();
                  if (!unmarshalAttributeGroup.containsAttributeInternal(mapping.getAttributeName())) {
                    continue;
                  }
                }
                attributeNodeValue.attribute(this,attNamespace,attLocalName,value);
              }
 else {
                if (xPathNode.getAnyAttributeNodeValue() != null) {
                  xPathNode.getAnyAttributeNodeValue().attribute(this,attNamespace,attLocalName,value);
                }
              }
            }
 catch (            EclipseLinkException e) {
              if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
                throw e;
              }
 else {
                SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),getDocumentLocator(),e);
                xmlReader.getErrorHandler().warning(saxParseException);
              }
            }
          }
        }
      }
    }
    if (prefixesForFragment != null) {
      this.prefixesForFragment.clear();
    }
  }
 catch (  EclipseLinkException e) {
    if ((null == xmlReader) || (null == xmlReader.getErrorHandler())) {
      throw e;
    }
 else {
      SAXParseException saxParseException=new SAXParseException(e.getLocalizedMessage(),getDocumentLocator(),e);
      xmlReader.getErrorHandler().error(saxParseException);
    }
  }
}