Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1017

Two jcr:roorVersion objects in VersionHistory.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.4.0.Final, 2.2.1.GA
    • 2.2.1.GA
    • JCR
    • None

    Description

      When we use the following code then the second call to the printVersions method will print the jcr:rootVersion twice. The problem lies in JcrVersionManager. See the WARN line comment in the sample code. The method printVersions just iterates over all Versions using the VersionIterator and prints the names to STD.

      CODE:

      Session session = RepositoryReferenceFactory.getRepository("test-jpa").login();
      ValueFactory vf = session.getValueFactory();

      Node root = session.getRootNode();
      Node file = root.addNode("createfile.mode", "nt:file");

      Node content = file.addNode("jcr:content", "nt:resource");
      content.setProperty("jcr:data", vf.createBinary(new ByteArrayInputStream("Write 1".getBytes())));
      session.save();

      file.addMixin("mix:versionable");
      //When session.save(); is not called then the following warning will be present in log. That's also the place in JcrVersionManger where the second root version will be added.
      //WARN ... Repaired version storage located at: /

      {http://www.jcp.org/jcr/1.0}

      system/

      {http://www.jcp.org/jcr/1.0}

      versionStorage/{}cc22bce9-a38b-4270-bb2a-492e41620a59
      //session.save();

      printVersions(session.getWorkspace().getVersionManager(), "/createfile.mode");
      session.save();
      printVersions(session.getWorkspace().getVersionManager(), "/createfile.mode");

      METHODS

      void printVersions(VersionManager vm, String path) throws Exception {
      System.out.println("------------ Versions ------------");
      VersionIterator i = vm.getVersionHistory(path).getAllVersions();
      while(i.hasNext())

      { System.out.println("Version: " + i.nextVersion().getName()); }

      System.out.println("----------------------------------\n");
      }

      Attachments

        Activity

          People

            bcarothers_jira Brian Carothers (Inactive)
            mbaluch@redhat.com Marek Baluch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: