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

Lock.getSecondsRemaining() does not provide actual time-to-live

    Details

    • Steps to Reproduce:
      Hide
          @Test
          public void shouldProvideActualSecondsRemaining() throws Exception {
              // Create a new lockable node
              Node node = session.getRootNode().addNode("test");
              node.addMixin("mix:lockable");
              session.save();
              String path = node.getPath();
      
              // Lock the node
              int timeout = 4;
              JcrLockManager lockManager = session.getWorkspace().getLockManager();
              Lock lock = lockManager.lock(node.getPath(), false, false, timeout, null);
              assertTrue(node.isLocked());
              assertNotEquals(Long.MAX_VALUE, lock.getSecondsRemaining());
              assertTrue(lock.getSecondsRemaining() <= timeout);
      
              // Wait enough time to see the change in seconds remaining
              Thread.sleep(TimeUnit.SECONDS.toMillis(timeout / 2));
              assertTrue(lock.getSecondsRemaining() <= timeout / 2);
      
              // Look at the same lock from another session
              session.logout();
              session = repository.login();
              lockManager = session.getWorkspace().getLockManager();
              lock = lockManager.getLock(path);
              assertTrue(lock.getSecondsRemaining() > 0);
              assertNotEquals(Long.MAX_VALUE, lock.getSecondsRemaining());
              assertTrue(lock.getSecondsRemaining() <= timeout);
      
          }
      
      Show
      @Test public void shouldProvideActualSecondsRemaining() throws Exception { // Create a new lockable node Node node = session.getRootNode().addNode( "test" ); node.addMixin( "mix:lockable" ); session.save(); String path = node.getPath(); // Lock the node int timeout = 4; JcrLockManager lockManager = session.getWorkspace().getLockManager(); Lock lock = lockManager.lock(node.getPath(), false , false , timeout, null ); assertTrue(node.isLocked()); assertNotEquals( Long .MAX_VALUE, lock.getSecondsRemaining()); assertTrue(lock.getSecondsRemaining() <= timeout); // Wait enough time to see the change in seconds remaining Thread .sleep(TimeUnit.SECONDS.toMillis(timeout / 2)); assertTrue(lock.getSecondsRemaining() <= timeout / 2); // Look at the same lock from another session session.logout(); session = repository.login(); lockManager = session.getWorkspace().getLockManager(); lock = lockManager.getLock(path); assertTrue(lock.getSecondsRemaining() > 0); assertNotEquals( Long .MAX_VALUE, lock.getSecondsRemaining()); assertTrue(lock.getSecondsRemaining() <= timeout); }

      Description

      For an open-scoped lock which is created with timeout hint less than Long.MAX_VALUE Lock.getSecondsRemaining() returns Long.MAX_VALUE (for a Lock object obtained via the session that created the lock) or negative value (for a Lock object obtained via another session).

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                hchiorean Horia Chiorean
                Reporter:
                zcc39r Rustam Usmanov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: