Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-2912

VersionManager.restore fails with ItemExitsException although the removeExisting parameter is set to true

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.2.4
    • None
    • jackrabbit-core, versioning
    • None

    Description

      In some cases versionManager.restore(versionManager.getBaseVersion(jcrNode.getPath()), true); fails with the following stack trace:

      Caused by: javax.jcr.ItemExistsException: 22437573-07b6-4dcd-8819-31b2c98dbf9d/

      {http://my.namespace}

      mynode
      at org.apache.jackrabbit.core.version.NodeStateEx.moveFrom(NodeStateEx.java:603)
      at org.apache.jackrabbit.core.version.VersionManagerImplRestore.internalRestoreFrozen(VersionManagerImplRestore.java:561)
      at org.apache.jackrabbit.core.version.VersionManagerImplRestore.internalRestore(VersionManagerImplRestore.java:294)
      at org.apache.jackrabbit.core.version.VersionManagerImplRestore.internalRestore(VersionManagerImplRestore.java:240)
      at org.apache.jackrabbit.core.VersionManagerImpl.access$1300(VersionManagerImpl.java:72)
      at org.apache.jackrabbit.core.VersionManagerImpl$6.perform(VersionManagerImpl.java:247)
      at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:200)
      at org.apache.jackrabbit.core.VersionManagerImpl.perform(VersionManagerImpl.java:95)
      at org.apache.jackrabbit.core.VersionManagerImpl.restore(VersionManagerImpl.java:221)
      at org.apache.jackrabbit.core.VersionManagerImpl.restore(VersionManagerImpl.java:213)

      I've figured out that the restoration only fails if the reference comparison in VersionManagerImplRestore in line 557:

      if (restoredChild.getParentId() == state.getNodeId()) {

      fails, although restoredChild.getParendId().compareTo(state.getNodeId()) returns 0.

      Changing the comparison to:

      if (restoredChild.getParentId().compareTo(state.getNodeId()) == 0) {

      solves the problem. Could you please tell me if the NodeId comparison suffices in this case? If so, could you please fix it in the next jackrabbit version? Thank you!

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              marlis Marlis Lamp
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0.5h
                  0.5h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified