• Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.2.0.Final
    • Fix Version/s: 4.3.0.Final
    • Component/s: Server
    • Labels:


      I am trying to copy a locked node using session.getWorkspace().copy(). From the documentation of copy, it is stated that:

      * @throws LockException                if a lock prevents the copy.

      It is not entirely clear to me what that means, but looking into the code for copy, I have deduced that you need to add the lock token (to the lock manager) of the node you wish to copy.

      Not doing this, results in a NullPointerException (and not a LockException) because the token is not there:

      Caused by: java.lang.NullPointerException
              at java.util.concurrent.ConcurrentHashMap.hash( [rt.jar:1.7.0_65]
              at java.util.concurrent.ConcurrentHashMap.containsKey( [rt.jar:1.7.0_65]
              at java.util.Collections$SetFromMap.contains( [rt.jar:1.7.0_65]
              at org.modeshape.jcr.JcrLockManager.hasLockToken( [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
              at org.modeshape.jcr.JcrWorkspace.copy( [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]
              at org.modeshape.jcr.JcrWorkspace.copy( [modeshape-jcr-4.2.0.Final.jar:4.2.0.Final]

      Adding the token still results in a NullPointerException and I believe it is because of this code in the copy method:

          * Find the source node and check if it is locked
          JcrSession sourceSession = session.spawnSession(srcWorkspace, true);
          AbstractJcrNode sourceNode = sourceSession.node(srcPath);
          if (session.lockManager().isLocked(sourceNode) && !session.lockManager().hasLockToken(sourceNode.getLock().getLockToken())) {
            throw new LockException(srcAbsPath);

      The session.lockManager() has indeed the lock token. But sourceNode.getLock().getLockToken() is still null since its lock manager is associated to the spawned session (sourceSession).

      So maybe the problem is that lock tokens in the lock manager of a spawned session are not inherited from the lock manager of the session it was spawned from?

        Gliffy Diagrams




              • Assignee:
                hchiorean Horia Chiorean
                jacobilsoe Jacob Ilsø
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: