Program: 65072
Project: 65072
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);
    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);
        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) {
          resultNode=xPathNode.getAnyNode();
        }
      }
    }
    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);
    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) {
          resultNode=xPathNode.getAnyNode();
        }
      }
    }
    return resultNode;
  }
  return null;
}