Program: 48259
Project: 48259
Buggy source:
@Override public synchronized void setQName(@Nonnull final QName pQName) throws AbsTTException {
  checkNotNull(pQName);
  if (getNode() instanceof INameNode) {
    if (!getQNameOfCurrentNode().equals(pQName)) {
      checkAccessAndCommit();
      INameNode node=(INameNode)mNodeReadRtx.getNode();
      final long oldHash=node.hashCode();
      final EKind nodeKind=node.getKind();
      final int oldNameKey=node.getNameKey();
      final int oldUriKey=node.getURIKey();
      final NamePage page=((NamePage)getPageTransaction().getActualRevisionRootPage().getNamePageReference().getPage());
      page.removeName(oldNameKey,nodeKind);
      page.removeName(oldUriKey,EKind.NAMESPACE);
      final int nameKey=getPageTransaction().createNameKey(PageWriteTrx.buildName(pQName),node.getKind());
      final int uriKey=getPageTransaction().createNameKey(pQName.getNamespaceURI(),EKind.NAMESPACE);
      movePathSummary();
      if (((PathNode)mPathSummary.getNode()).getReferences() == 1) {
        final PathNode pathNode=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
        pathNode.setNameKey(nameKey);
        pathNode.setURIKey(uriKey);
        getPageTransaction().finishNodeModification(pathNode,EPage.PATHSUMMARYPAGE);
      }
 else {
        final PathNode pathNode=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
        pathNode.decrementReferenceCount();
        getPageTransaction().finishNodeModification(pathNode,EPage.PATHSUMMARYPAGE);
        moveToParent();
        int level=0;
        if (mNodeReadRtx.getNode().getKind() == EKind.DOCUMENT_ROOT) {
          mPathSummary.moveToDocumentRoot();
        }
 else {
          movePathSummary();
          level=mPathSummary.getPathNode().getLevel();
        }
        moveTo(node.getNodeKey());
        final IAxis axis=new FilterAxis(new ChildAxis(mPathSummary),new NameFilter(mPathSummary,pQName.getLocalPart()));
        if (axis.hasNext()) {
          axis.next();
          final PathNode path=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
          path.incrementReferenceCount();
          getPageTransaction().finishNodeModification(path,EPage.PATHSUMMARYPAGE);
        }
 else {
          for (final IAxis descendants=new DescendantAxis(this,EIncludeSelf.YES); descendants.hasNext(); ) {
            descendants.next();
            if (axis.getTransaction().getNode().getKind() == EKind.ELEMENT) {
              final ElementNode element=(ElementNode)axis.getTransaction().getNode();
              insertPathAsFirstChild(axis.getTransaction().getQNameOfCurrentNode(),nodeKind,level);
              for (int i=0, nsps=element.getNamespaceCount(); i < nsps; i++) {
                moveToNamespace(i);
                insertPathAsFirstChild(axis.getTransaction().getQNameOfCurrentNode(),nodeKind,level);
                moveToParent();
                mPathSummary.moveToParent();
              }
              for (int i=0, atts=element.getAttributeCount(); i < atts; i++) {
                moveToAttribute(i);
                insertPathAsFirstChild(axis.getTransaction().getQNameOfCurrentNode(),nodeKind,level);
                moveToParent();
                mPathSummary.moveToParent();
              }
            }
          }
        }
      }
      node=(INameNode)getPageTransaction().prepareNodeForModification(mNodeReadRtx.getNode().getNodeKey(),EPage.NODEPAGE);
      node.setNameKey(nameKey);
      node.setURIKey(uriKey);
      node.setPathNodeKey(mPathSummary.getNode().getNodeKey());
      getPageTransaction().finishNodeModification(node,EPage.NODEPAGE);
      mNodeReadRtx.setCurrentNode(node);
      adaptHashedWithUpdate(oldHash);
    }
  }
 else {
    throw new TTUsageException("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public synchronized void setQName(@Nonnull final QName pQName) throws AbsTTException {
  checkNotNull(pQName);
  if (getNode() instanceof INameNode) {
    if (!getQNameOfCurrentNode().equals(pQName)) {
      checkAccessAndCommit();
      INameNode node=(INameNode)mNodeReadRtx.getNode();
      final long oldHash=node.hashCode();
      final EKind nodeKind=node.getKind();
      final int oldNameKey=node.getNameKey();
      final int oldUriKey=node.getURIKey();
      final NamePage page=((NamePage)getPageTransaction().getActualRevisionRootPage().getNamePageReference().getPage());
      page.removeName(oldNameKey,nodeKind);
      page.removeName(oldUriKey,EKind.NAMESPACE);
      final int nameKey=getPageTransaction().createNameKey(PageWriteTrx.buildName(pQName),node.getKind());
      final int uriKey=getPageTransaction().createNameKey(pQName.getNamespaceURI(),EKind.NAMESPACE);
      movePathSummary();
      if (((PathNode)mPathSummary.getNode()).getReferences() == 1) {
        final PathNode pathNode=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
        pathNode.setNameKey(nameKey);
        pathNode.setURIKey(uriKey);
        getPageTransaction().finishNodeModification(pathNode,EPage.PATHSUMMARYPAGE);
      }
 else {
        final PathNode pathNode=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
        pathNode.decrementReferenceCount();
        getPageTransaction().finishNodeModification(pathNode,EPage.PATHSUMMARYPAGE);
        moveToParent();
        int level=0;
        if (mNodeReadRtx.getNode().getKind() == EKind.DOCUMENT_ROOT) {
          mPathSummary.moveToDocumentRoot();
        }
 else {
          movePathSummary();
          level=mPathSummary.getPathNode().getLevel();
        }
        moveTo(node.getNodeKey());
        final IAxis axis=new FilterAxis(new ChildAxis(mPathSummary),new NameFilter(mPathSummary,pQName.getLocalPart()));
        if (axis.hasNext()) {
          axis.next();
          final PathNode path=(PathNode)getPageTransaction().prepareNodeForModification(mPathSummary.getNode().getNodeKey(),EPage.PATHSUMMARYPAGE);
          path.incrementReferenceCount();
          getPageTransaction().finishNodeModification(path,EPage.PATHSUMMARYPAGE);
          adaptNode(node,nameKey,uriKey);
        }
 else {
          adaptNode(node,nameKey,uriKey);
          boolean firstRun=true;
          for (final IAxis descendants=new DescendantAxis(this,EIncludeSelf.YES); descendants.hasNext(); ) {
            descendants.next();
            if (descendants.getTransaction().getNode().getKind() == EKind.ELEMENT) {
              final ElementNode element=(ElementNode)descendants.getTransaction().getNode();
              insertPathAsFirstChild(descendants.getTransaction().getQNameOfCurrentNode(),EKind.ELEMENT,++level);
              for (int i=0, nsps=element.getNamespaceCount(); i < nsps; i++) {
                moveToNamespace(i);
                insertPathAsFirstChild(descendants.getTransaction().getQNameOfCurrentNode(),EKind.NAMESPACE,level);
                resetPathNodeKey(getNode().getNodeKey());
                moveToParent();
                mPathSummary.moveToParent();
              }
              for (int i=0, atts=element.getAttributeCount(); i < atts; i++) {
                moveToAttribute(i);
                insertPathAsFirstChild(descendants.getTransaction().getQNameOfCurrentNode(),EKind.ATTRIBUTE,level);
                resetPathNodeKey(getNode().getNodeKey());
                moveToParent();
                mPathSummary.moveToParent();
              }
              if (firstRun) {
                firstRun=false;
              }
 else {
                mPathSummary.moveToParent();
                level--;
              }
            }
          }
        }
      }
      mNodeReadRtx.setCurrentNode(node);
      adaptHashedWithUpdate(oldHash);
    }
  }
 else {
    throw new TTUsageException("String_Node_Str");
  }
}