Program: 48211
Project: 48211
Buggy source:
/** 
 * Create a page write trx.
 * @param resourceManager {@link XdmResourceManager} this page write trx is bound to
 * @param uberPage root of revision
 * @param writer writer where this transaction should write to
 * @param trxId the transaction ID
 * @param representRev revision represent
 * @param lastStoredRev last stored revision
 * @param bufferManager the page cache buffer
 */
public PageWriteTrx<Long,Record,UnorderedKeyValuePage> createPageWriteTrx(final XdmResourceManager resourceManager,final UberPage uberPage,final Writer writer,final @Nonnegative long trxId,final @Nonnegative int representRev,final @Nonnegative int lastStoredRev,final @Nonnegative int lastCommitedRev,final @Nonnull BufferManager bufferManager){
  final boolean usePathSummary=resourceManager.getResourceConfig().mPathSummary;
  final IndexController indexController=resourceManager.getWtxIndexController(representRev);
  final Path indexes=resourceManager.getResourceConfig().mPath.resolve(ResourceConfiguration.ResourcePaths.INDEXES.getFile()).resolve(String.valueOf(lastStoredRev) + "String_Node_Str");
  if (Files.exists(indexes)) {
    try (final InputStream in=new FileInputStream(indexes.toFile())){
      indexController.getIndexes().init(IndexController.deserialize(in).getFirstChild());
    }
 catch (    IOException|DocumentException|SirixException e) {
      throw new SirixIOException("String_Node_Str",e);
    }
  }
  final TreeModifierImpl treeModifier=new TreeModifierImpl();
  final TransactionIntentLogFactory logFactory=new TransactionIntentLogFactoryImpl();
  final TransactionIntentLog log=logFactory.createTrxIntentLog(resourceManager.getResourceConfig());
  if (uberPage.isBootstrap()) {
    uberPage.createRevisionTree(log);
  }
  final PageReadTrxImpl pageRtx=new PageReadTrxImpl(trxId,resourceManager,uberPage,representRev,writer,log,indexController,bufferManager);
  final RevisionRootPage lastCommitedRoot=pageRtx.loadRevRoot(lastCommitedRev);
  final RevisionRootPage newRevisionRootPage=treeModifier.preparePreviousRevisionRootPage(uberPage,pageRtx,log,representRev,lastStoredRev);
  newRevisionRootPage.setMaxNodeKey(lastCommitedRoot.getMaxNodeKey());
  newRevisionRootPage.createNodeTree(pageRtx,log);
  if (usePathSummary) {
    final PathSummaryPage page=pageRtx.getPathSummaryPage(newRevisionRootPage);
    page.createPathSummaryTree(pageRtx,0,log);
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getPathSummaryPageReference(),pageRtx)))     log.put(newRevisionRootPage.getPathSummaryPageReference(),new PageContainer(page,page));
  }
  if (!uberPage.isBootstrap()) {
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getNamePageReference(),pageRtx))) {
      final Page namePage=pageRtx.getNamePage(newRevisionRootPage);
      log.put(newRevisionRootPage.getNamePageReference(),new PageContainer(namePage,namePage));
    }
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getCASPageReference(),pageRtx))) {
      final Page casPage=pageRtx.getCASPage(newRevisionRootPage);
      log.put(newRevisionRootPage.getCASPageReference(),new PageContainer(casPage,casPage));
    }
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getPathPageReference(),pageRtx))) {
      final Page pathPage=pageRtx.getPathPage(newRevisionRootPage);
      log.put(newRevisionRootPage.getPathPageReference(),new PageContainer(pathPage,pathPage));
    }
    final Page indirectPage=pageRtx.dereferenceIndirectPageReference(newRevisionRootPage.getIndirectPageReference());
    log.put(newRevisionRootPage.getIndirectPageReference(),new PageContainer(indirectPage,indirectPage));
    final PageReference revisionRootPageReference=treeModifier.prepareLeafOfTree(pageRtx,log,uberPage.getPageCountExp(PageKind.UBERPAGE),uberPage.getIndirectPageReference(),uberPage.getRevisionNumber(),-1,PageKind.UBERPAGE);
    log.put(revisionRootPageReference,new PageContainer(newRevisionRootPage,newRevisionRootPage));
  }
  return new PageWriteTrxImpl(treeModifier,writer,log,newRevisionRootPage,pageRtx,indexController);
}

Fixed version (ground truth):
/** 
 * Create a page write trx.
 * @param resourceManager {@link XdmResourceManager} this page write trx is bound to
 * @param uberPage root of revision
 * @param writer writer where this transaction should write to
 * @param trxId the transaction ID
 * @param representRev revision represent
 * @param lastStoredRev last stored revision
 * @param bufferManager the page cache buffer
 */
public PageWriteTrx<Long,Record,UnorderedKeyValuePage> createPageWriteTrx(final XdmResourceManager resourceManager,final UberPage uberPage,final Writer writer,final @Nonnegative long trxId,final @Nonnegative int representRev,final @Nonnegative int lastStoredRev,final @Nonnegative int lastCommitedRev,final @Nonnull BufferManager bufferManager){
  final boolean usePathSummary=resourceManager.getResourceConfig().mPathSummary;
  final IndexController indexController=resourceManager.getWtxIndexController(representRev);
  final Path indexes=resourceManager.getResourceConfig().mPath.resolve(ResourceConfiguration.ResourcePaths.INDEXES.getPath()).resolve(String.valueOf(lastStoredRev) + "String_Node_Str");
  if (Files.exists(indexes)) {
    try (final InputStream in=new FileInputStream(indexes.toFile())){
      indexController.getIndexes().init(IndexController.deserialize(in).getFirstChild());
    }
 catch (    IOException|DocumentException|SirixException e) {
      throw new SirixIOException("String_Node_Str",e);
    }
  }
  final TreeModifierImpl treeModifier=new TreeModifierImpl();
  final TransactionIntentLogFactory logFactory=new TransactionIntentLogFactoryImpl();
  final TransactionIntentLog log=logFactory.createTrxIntentLog(resourceManager.getResourceConfig());
  if (uberPage.isBootstrap()) {
    uberPage.createRevisionTree(log);
  }
  final PageReadTrxImpl pageRtx=new PageReadTrxImpl(trxId,resourceManager,uberPage,representRev,writer,log,indexController,bufferManager);
  final RevisionRootPage lastCommitedRoot=pageRtx.loadRevRoot(lastCommitedRev);
  final RevisionRootPage newRevisionRootPage=treeModifier.preparePreviousRevisionRootPage(uberPage,pageRtx,log,representRev,lastStoredRev);
  newRevisionRootPage.setMaxNodeKey(lastCommitedRoot.getMaxNodeKey());
  newRevisionRootPage.createNodeTree(pageRtx,log);
  if (usePathSummary) {
    final PathSummaryPage page=pageRtx.getPathSummaryPage(newRevisionRootPage);
    page.createPathSummaryTree(pageRtx,0,log);
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getPathSummaryPageReference(),pageRtx)))     log.put(newRevisionRootPage.getPathSummaryPageReference(),new PageContainer(page,page));
  }
  if (!uberPage.isBootstrap()) {
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getNamePageReference(),pageRtx))) {
      final Page namePage=pageRtx.getNamePage(newRevisionRootPage);
      log.put(newRevisionRootPage.getNamePageReference(),new PageContainer(namePage,namePage));
    }
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getCASPageReference(),pageRtx))) {
      final Page casPage=pageRtx.getCASPage(newRevisionRootPage);
      log.put(newRevisionRootPage.getCASPageReference(),new PageContainer(casPage,casPage));
    }
    if (PageContainer.emptyInstance().equals(log.get(newRevisionRootPage.getPathPageReference(),pageRtx))) {
      final Page pathPage=pageRtx.getPathPage(newRevisionRootPage);
      log.put(newRevisionRootPage.getPathPageReference(),new PageContainer(pathPage,pathPage));
    }
    final Page indirectPage=pageRtx.dereferenceIndirectPageReference(newRevisionRootPage.getIndirectPageReference());
    log.put(newRevisionRootPage.getIndirectPageReference(),new PageContainer(indirectPage,indirectPage));
    final PageReference revisionRootPageReference=treeModifier.prepareLeafOfTree(pageRtx,log,uberPage.getPageCountExp(PageKind.UBERPAGE),uberPage.getIndirectPageReference(),uberPage.getRevisionNumber(),-1,PageKind.UBERPAGE);
    log.put(revisionRootPageReference,new PageContainer(newRevisionRootPage,newRevisionRootPage));
  }
  return new PageWriteTrxImpl(treeModifier,writer,log,newRevisionRootPage,pageRtx,indexController);
}