Program: 63683
Project: 63683
Buggy source:
/** 
 * INTERNAL:
 */
public XPathNode getNonAttributeXPathNode(String namespaceURI,String localName,String qName,Attributes attributes){
  if (0 == levelIndex) {
    return xPathNode;
  }
  if (namespaceURI != null && namespaceURI.length() == 0) {
    xPathFragment.setLocalName(qName);
    xPathFragment.setNamespaceURI(null);
  }
 else {
    xPathFragment.setLocalName(localName);
    xPathFragment.setNamespaceURI(namespaceURI);
  }
  XPathNode resultNode=null;
  Map nonAttributeChildrenMap=xPathNode.getNonAttributeChildrenMap();
  if (null != nonAttributeChildrenMap) {
    resultNode=(XPathNode)nonAttributeChildrenMap.get(xPathFragment);
    XPathNode nonPredicateNode=null;
    if (resultNode != null && resultNode.hasPredicateSiblings()) {
      nonPredicateNode=resultNode;
      resultNode=null;
    }
    if (null == resultNode) {
      int newIndex;
      if (null == this.indexMap) {
        this.indexMap=new HashMap();
        newIndex=1;
      }
 else {
        Integer oldIndex=indexMap.get(xPathFragment);
        if (null == oldIndex) {
          newIndex=1;
        }
 else {
          newIndex=oldIndex.intValue() + 1;
        }
      }
      indexMap.put(xPathFragment,newIndex);
      XPathFragment predicateFragment=new XPathFragment();
      predicateFragment.setNamespaceAware(isNamespaceAware());
      predicateFragment.setNamespaceURI(xPathFragment.getNamespaceURI());
      predicateFragment.setLocalName(xPathFragment.getLocalName());
      predicateFragment.setIndexValue(newIndex);
      resultNode=(XPathNode)nonAttributeChildrenMap.get(predicateFragment);
      if (null == resultNode) {
        predicateFragment.setIndexValue(-1);
        if (attributes != null) {
          for (int x=0, length=attributes.getLength(); x < length; x++) {
            XPathFragment conditionFragment=new XPathFragment();
            conditionFragment.setLocalName(attributes.getLocalName(x));
            conditionFragment.setNamespaceURI(attributes.getURI(x));
            conditionFragment.setAttribute(true);
            XPathPredicate condition=new XPathPredicate(conditionFragment,attributes.getValue(x));
            predicateFragment.setPredicate(condition);
            resultNode=(XPathNode)nonAttributeChildrenMap.get(predicateFragment);
            if (null != resultNode) {
              break;
            }
          }
        }
        if (null == resultNode && null == nonPredicateNode) {
          resultNode=xPathNode.getAnyNode();
        }
      }
    }
    if (resultNode == null && nonPredicateNode != null) {
      return nonPredicateNode;
    }
    return resultNode;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * INTERNAL:
 */
public XPathNode getNonAttributeXPathNode(String namespaceURI,String localName,String qName,Attributes attributes){
  if (0 == levelIndex) {
    return xPathNode;
  }
  if (namespaceURI != null && namespaceURI.length() == 0) {
    xPathFragment.setLocalName(qName);
    xPathFragment.setNamespaceURI(null);
  }
 else {
    xPathFragment.setLocalName(localName);
    xPathFragment.setNamespaceURI(namespaceURI);
  }
  XPathNode resultNode=null;
  Map nonAttributeChildrenMap=xPathNode.getNonAttributeChildrenMap();
  if (null != nonAttributeChildrenMap) {
    resultNode=(XPathNode)nonAttributeChildrenMap.get(xPathFragment);
    XPathNode nonPredicateNode=null;
    if (resultNode != null && resultNode.hasPredicateSiblings()) {
      nonPredicateNode=resultNode;
      resultNode=null;
    }
    if (null == resultNode) {
      int newIndex;
      if (null == this.indexMap) {
        this.indexMap=new HashMap();
        newIndex=1;
      }
 else {
        Integer oldIndex=indexMap.get(xPathFragment);
        if (null == oldIndex) {
          newIndex=1;
        }
 else {
          newIndex=oldIndex.intValue() + 1;
        }
      }
      indexMap.put(xPathFragment,newIndex);
      XPathFragment predicateFragment=new XPathFragment();
      predicateFragment.setNamespaceAware(isNamespaceAware());
      predicateFragment.setNamespaceURI(xPathFragment.getNamespaceURI());
      predicateFragment.setLocalName(xPathFragment.getLocalName());
      predicateFragment.setIndexValue(newIndex);
      resultNode=(XPathNode)nonAttributeChildrenMap.get(predicateFragment);
      if (null == resultNode) {
        predicateFragment.setIndexValue(-1);
        if (attributes != null) {
          for (int x=0, length=attributes.getLength(); x < length; x++) {
            XPathFragment conditionFragment=new XPathFragment();
            conditionFragment.setLocalName(attributes.getLocalName(x));
            conditionFragment.setNamespaceURI(attributes.getURI(x));
            conditionFragment.setAttribute(true);
            XPathPredicate condition=new XPathPredicate(conditionFragment,attributes.getValue(x));
            predicateFragment.setPredicate(condition);
            resultNode=(XPathNode)nonAttributeChildrenMap.get(predicateFragment);
            if (null != resultNode) {
              break;
            }
          }
        }
        if (null == resultNode && xPathNode.getTextNode() != null) {
          XPathFragment textWrapperFragment=getTextWrapperFragment();
          if (textWrapperFragment != null && localName.equals(textWrapperFragment.getLocalName())) {
            resultNode=xPathNode.getTextNode();
          }
        }
        if (null == resultNode && null == nonPredicateNode) {
          resultNode=xPathNode.getAnyNode();
        }
      }
    }
    if (resultNode == null && nonPredicateNode != null) {
      return nonPredicateNode;
    }
    return resultNode;
  }
  return null;
}