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

Session scoped locks broken in 3.8.x with JTA

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • 4.1.0.Final
    • 3.8.1.Final
    • JCR
    • None
    • Hide
      public class JBossTransactionsTest extends SingleUseAbstractTest {
      
          @Test
          public void testLocks() throws Exception {
              InputStream configStream = getClass().getClassLoader().getResourceAsStream(
                      "config/repo-config-inmemory-jbosstxn.json");
              RepositoryConfiguration config = RepositoryConfiguration.read(configStream, REPO_NAME).with(environment);
              repository = new JcrRepository(config);
              repository.start();
              TransactionManager txman = repository.transactionManager();
              //add lockable node
              Session sess = repository.login();
              Node genNode = sess.getRootNode().addNode("lockable");
              genNode.addMixin("mix:lockable");
              genNode.getSession().save();
              sess.logout();
              //test lock
              txman.begin();
              sess = repository.login();
              LockManager lockManager = sess.getWorkspace().getLockManager();
              lockManager.lock("/lockable", false, true, Long.MAX_VALUE, null);
              sess.logout();
              txman.commit();
          }
      
          protected boolean startRepositoryAutomatically() {
              return false;
          }
      }
      
      Show
      public class JBossTransactionsTest extends SingleUseAbstractTest { @Test public void testLocks() throws Exception { InputStream configStream = getClass().getClassLoader().getResourceAsStream( "config/repo-config-inmemory-jbosstxn.json" ); RepositoryConfiguration config = RepositoryConfiguration.read(configStream, REPO_NAME).with(environment); repository = new JcrRepository(config); repository.start(); TransactionManager txman = repository.transactionManager(); //add lockable node Session sess = repository.login(); Node genNode = sess.getRootNode().addNode( "lockable" ); genNode.addMixin( "mix:lockable" ); genNode.getSession().save(); sess.logout(); //test lock txman.begin(); sess = repository.login(); LockManager lockManager = sess.getWorkspace().getLockManager(); lockManager.lock( "/lockable" , false , true , Long .MAX_VALUE, null ); sess.logout(); txman.commit(); } protected boolean startRepositoryAutomatically() { return false ; } }

      ModeShape throws exception on session logout after create session-scoped lock under transaction:

      JBossTransactionsTest
      org.modeshape.jcr.JBossTransactionsTest
      testLockedGenerator(org.modeshape.jcr.JBossTransactionsTest)
      org.modeshape.jcr.cache.NodeNotFoundInParentException: Cannot locate child node: dd0135d317f1e7mode:lock-dd0135d7505d649d8b0c45-ced2-45b8-82f0-8d6812a31546 within parent: dd0135d317f1e7mode:locks
      	at org.modeshape.jcr.cache.document.LazyCachedNode.parentReferenceToSelf(LazyCachedNode.java:251)
      	at org.modeshape.jcr.cache.document.LazyCachedNode.getSegment(LazyCachedNode.java:288)
      	at org.modeshape.jcr.cache.document.LazyCachedNode.getPath(LazyCachedNode.java:314)
      	at org.modeshape.jcr.cache.PathCache.getPath(PathCache.java:49)
      	at org.modeshape.jcr.cache.document.WritableSessionCache.persistChanges(WritableSessionCache.java:954)
      	at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:634)
      	at org.modeshape.jcr.cache.SessionCacheWrapper.save(SessionCacheWrapper.java:103)
      	at org.modeshape.jcr.JcrSession$SystemSessionCache.save(JcrSession.java:2444)
      	at org.modeshape.jcr.RepositoryLockManager.unlock(RepositoryLockManager.java:415)
      	at org.modeshape.jcr.RepositoryLockManager.cleanLocks(RepositoryLockManager.java:435)
      	at org.modeshape.jcr.JcrLockManager.cleanLocks(JcrLockManager.java:74)
      	at org.modeshape.jcr.JcrSession.cleanLocks(JcrSession.java:289)
      	at org.modeshape.jcr.JcrSession.terminate(JcrSession.java:282)
      	at org.modeshape.jcr.JcrSession.logout(JcrSession.java:1755)
      	at org.modeshape.jcr.JBossTransactionsTest.testLocks(JBossTransactionsTest.java:47)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      

      Bug is not reproduced with ModeShape 3.8.0 or 4.x

              hchiorean Horia Chiorean (Inactive)
              bIgorek Igor Bezrukov (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: