Program: 68493
Project: 68493
Buggy source:
public void addChild(XPathFragment anXPathFragment,NodeValue aNodeValue,NamespaceResolver namespaceResolver){
  if (anXPathFragment != null && namespaceResolver != null) {
    if (!anXPathFragment.isAttribute()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
 else     if (anXPathFragment.hasNamespace()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
  }
  XPathNode xPathNode=new XPathNode();
  xPathNode.setXPathFragment(anXPathFragment);
  List children;
  Map childrenMap;
  if ((anXPathFragment != null) && anXPathFragment.isAttribute()) {
    if (null == attributeChildren) {
      attributeChildren=new ArrayList();
      attributeChildrenMap=new HashMap();
    }
    children=attributeChildren;
    childrenMap=attributeChildrenMap;
  }
 else {
    if (null == nonAttributeChildren) {
      nonAttributeChildren=new ArrayList();
      nonAttributeChildrenMap=new HashMap();
    }
    children=nonAttributeChildren;
    childrenMap=nonAttributeChildrenMap;
  }
  if (null == anXPathFragment) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
    xPathNode.setParent(this);
    if (aNodeValue instanceof XMLAnyAttributeMappingNodeValue) {
      setAnyAttributeNodeValue((XMLAnyAttributeMappingNodeValue)aNodeValue);
      anyAttributeNode=xPathNode;
    }
 else {
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
    return;
  }
  int index=children.indexOf(xPathNode);
  if (index >= 0) {
    xPathNode=(XPathNode)children.get(index);
  }
 else {
    xPathNode.setParent(this);
    if (!children.contains(xPathNode)) {
      children.add(xPathNode);
    }
    if (XPathFragment.SELF_FRAGMENT.equals(anXPathFragment)) {
      if (null == selfChildren) {
        selfChildren=new ArrayList();
      }
      if (!selfChildren.contains(xPathNode)) {
        selfChildren.add(xPathNode);
      }
    }
 else {
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
  }
 else {
    XPathFragment nextFragment=anXPathFragment.getNextFragment();
    xPathNode.addChild(nextFragment,aNodeValue,namespaceResolver);
  }
}

Fixed version (ground truth):
public void addChild(XPathFragment anXPathFragment,NodeValue aNodeValue,NamespaceResolver namespaceResolver){
  if (anXPathFragment != null && namespaceResolver != null && anXPathFragment.getNamespaceURI() == null) {
    if (!anXPathFragment.isAttribute()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
 else     if (anXPathFragment.hasNamespace()) {
      anXPathFragment.setNamespaceURI(namespaceResolver.resolveNamespacePrefix(anXPathFragment.getPrefix()));
    }
  }
  XPathNode xPathNode=new XPathNode();
  xPathNode.setXPathFragment(anXPathFragment);
  List children;
  Map childrenMap;
  if ((anXPathFragment != null) && anXPathFragment.isAttribute()) {
    if (null == attributeChildren) {
      attributeChildren=new ArrayList();
      attributeChildrenMap=new HashMap();
    }
    children=attributeChildren;
    childrenMap=attributeChildrenMap;
  }
 else {
    if (null == nonAttributeChildren) {
      nonAttributeChildren=new ArrayList();
      nonAttributeChildrenMap=new HashMap();
    }
    children=nonAttributeChildren;
    childrenMap=nonAttributeChildrenMap;
  }
  if (null == anXPathFragment) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
    xPathNode.setParent(this);
    if (aNodeValue instanceof XMLAnyAttributeMappingNodeValue) {
      setAnyAttributeNodeValue((XMLAnyAttributeMappingNodeValue)aNodeValue);
      anyAttributeNode=xPathNode;
    }
 else {
      if (!children.contains(xPathNode)) {
        children.add(xPathNode);
      }
      childrenMap.put(anXPathFragment,xPathNode);
    }
    return;
  }
  int index=children.indexOf(xPathNode);
  if (index >= 0) {
    xPathNode=(XPathNode)children.get(index);
  }
 else {
    xPathNode.setParent(this);
    if (!children.contains(xPathNode)) {
      children.add(xPathNode);
    }
    if (XPathFragment.SELF_FRAGMENT.equals(anXPathFragment)) {
      if (null == selfChildren) {
        selfChildren=new ArrayList();
      }
      if (!selfChildren.contains(xPathNode)) {
        selfChildren.add(xPathNode);
      }
    }
 else {
      childrenMap.put(anXPathFragment,xPathNode);
    }
  }
  if (aNodeValue.isOwningNode(anXPathFragment)) {
    if (aNodeValue.isMarshalNodeValue()) {
      xPathNode.setMarshalNodeValue(aNodeValue);
    }
    if (aNodeValue.isUnmarshalNodeValue()) {
      xPathNode.setUnmarshalNodeValue(aNodeValue);
    }
  }
 else {
    XPathFragment nextFragment=anXPathFragment.getNextFragment();
    xPathNode.addChild(nextFragment,aNodeValue,namespaceResolver);
  }
}