Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.2.4
    • Fix Version/s: 2.3.6
    • Component/s: jackrabbit-core, versioning
    • Labels:
      None

      Description

      When restoring a versionable node which has several (non-versionable) child nodes with the same name, some child nodes disappear.

      Node node = session.getRootNode().addNode("myNode");
      node.addMixin("mix:versionable");
      for (int i = 1; i < 6; i++)

      { Node child = node.addNode("child"); child.setProperty("name", "child_"+i); }

      session.save();
      VersionManager versionManager = session.getWorkspace().getVersionManager();
      versionManager.checkin(node.getPath());
      System.out.println("number of child nodes: " + node.getNodes().getSize());

      versionManager.checkout(node.getPath());
      node.getNode("child").setProperty("name", "modified");
      session.save();
      Version baseVersion = versionManager.getBaseVersion(node.getPath());
      versionManager.restore(baseVersion, true);
      System.out.println("number of child nodes in restored node: "+node.getNodes().getSize());

      produces the following output:

      number of child nodes: 5
      number of child nodes in restored node: 3

      Giving unique names or adding the mixin versionable to the child nodes solves the problem.

      1. JCR-2930.diff
        6 kB
        Julian Reschke
      2. RestoreNodeWithSNSTest.java
        2 kB
        Julian Reschke
      3. VersionManagerImplRestore.patch
        2 kB
        Marlis Lamp

        Activity

        Marlis Lamp created issue -
        Stefan Guggisberg made changes -
        Field Original Value New Value
        Component/s versioning [ 11612 ]
        Marlis Lamp made changes -
        Attachment VersionManagerImplRestore.patch [ 12474609 ]
        Marlis Lamp made changes -
        Attachment VersionManagerImplRestore.patch [ 12474610 ]
        Marlis Lamp made changes -
        Attachment VersionManagerImplRestore.patch [ 12474609 ]
        Hide
        Marlis Lamp added a comment -

        The error occurs at org.apache.jackrabbit.core.version.VersionManagerImplRestore.internalRestoreFrozen(VersionManagerImpl.java:493) when replacing all existing child nodes on N:

        // if node is present, remove it
        state.removeNode(entry.getName(), entry.getIndex());

        Let N (node) and F (frozen node) have 2 child nodes.
        This removes the correct node from the state object at the first cycle, but at the second, when the first child node has been removed from position 1 and added to position 2 on the state object, the indices in the state object have moved and the childnode that has been added at the first cycle is removed at the second cycle. The second cycle also removes the 2nd child node from the state object in line 505:

        // check for existing
        if (f.getFrozenId() != null) {
        if (stateMgr.hasItemState(f.getFrozenId())) {
        NodeStateEx existing = state.getNode(f.getFrozenId());
        if (removeExisting) {
        NodeStateEx parent = existing.getParent();
        parent.removeNode(existing);
        parent.store();
        ...

        Finally the 2nd child node of F is added, resulting in a restored state, where the first child node of the frozen node is missing.

        Show
        Marlis Lamp added a comment - The error occurs at org.apache.jackrabbit.core.version.VersionManagerImplRestore.internalRestoreFrozen(VersionManagerImpl.java:493) when replacing all existing child nodes on N: // if node is present, remove it state.removeNode(entry.getName(), entry.getIndex()); Let N (node) and F (frozen node) have 2 child nodes. This removes the correct node from the state object at the first cycle, but at the second, when the first child node has been removed from position 1 and added to position 2 on the state object, the indices in the state object have moved and the childnode that has been added at the first cycle is removed at the second cycle. The second cycle also removes the 2nd child node from the state object in line 505: // check for existing if (f.getFrozenId() != null) { if (stateMgr.hasItemState(f.getFrozenId())) { NodeStateEx existing = state.getNode(f.getFrozenId()); if (removeExisting) { NodeStateEx parent = existing.getParent(); parent.removeNode(existing); parent.store(); ... Finally the 2nd child node of F is added, resulting in a restored state, where the first child node of the frozen node is missing.
        Julian Reschke made changes -
        Assignee Julian Reschke [ reschke ]
        Hide
        Julian Reschke added a comment -

        repro test case

        Show
        Julian Reschke added a comment - repro test case
        Julian Reschke made changes -
        Attachment RestoreNodeWithSNSTest.java [ 12507019 ]
        Julian Reschke made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Julian Reschke added a comment -

        proposed patch (minimally changed), includes test case

        Show
        Julian Reschke added a comment - proposed patch (minimally changed), includes test case
        Julian Reschke made changes -
        Attachment JCR-2930.diff [ 12507024 ]
        Hide
        Julian Reschke added a comment -

        Fixed based on Marlis Lamps patch (thanks!)

        Show
        Julian Reschke added a comment - Fixed based on Marlis Lamps patch (thanks!)
        Julian Reschke made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.4 [ 12318241 ]
        Resolution Fixed [ 1 ]
        Jukka Zitting made changes -
        Fix Version/s 2.3.6 [ 12319192 ]
        Fix Version/s 2.4 [ 12318241 ]
        Jukka Zitting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Julian Reschke
            Reporter:
            Marlis Lamp
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development