Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java (revision b4334ece2864a26ee5aa2320c2146536019558d8) +++ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/VersionManagementTest.java (revision ) @@ -16,11 +16,17 @@ */ package org.apache.jackrabbit.oak.jcr.security.authorization; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.FutureTask; + import javax.jcr.AccessDeniedException; import javax.jcr.ItemNotFoundException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Property; +import javax.jcr.RepositoryException; +import javax.jcr.Session; import javax.jcr.security.AccessControlEntry; import javax.jcr.security.AccessControlList; import javax.jcr.security.Privilege; @@ -28,6 +34,7 @@ import javax.jcr.version.VersionHistory; import javax.jcr.version.VersionManager; +import com.google.common.collect.Lists; import org.apache.jackrabbit.test.NotExecutableException; import org.junit.Before; import org.junit.Test; @@ -319,6 +326,52 @@ history.addVersionLabel(v.getName(), "testLabel", true); } + @Test + public void testManyVersions() throws Exception { + Node node = createVersionableNode(superuser.getNode(path)); + allow(node.getPath(), versionPrivileges); + + List> workers = Lists.newArrayList(); + for (int k = 0; k < 4; k++) { + workers.add(run(new Worker(node.getPath()))); + } + + for (FutureTask worker : workers) { + worker.get(); + } + } + + private static FutureTask run(Callable callable) { + FutureTask task = new FutureTask(callable); + new Thread(task).start(); + return task; + } + + private class Worker implements Callable { + private final Session session; + private final String vPath; + + public Worker(String vPath) throws RepositoryException { + this.session = getHelper().getSuperuserSession(); + this.vPath = vPath; + } + + @Override + public Void call() throws Exception { + VersionManager versionManager = session.getWorkspace().getVersionManager(); + for (int k = 0; k < 1000; k++) { + try { + Version version = versionManager.checkin(vPath); + versionManager.checkout(vPath); + String label = version.getName() + " " + Thread.currentThread().getName(); + System.out.println(label); + version.getContainingHistory().addVersionLabel(version.getName(), label, true); + } catch (RepositoryException ignore) { } + } + return null; + } + } + /** * @since oak */ @@ -403,4 +456,5 @@ Property versionablePath = vh.getProperty(superuser.getWorkspace().getName()); assertEquals(testNode.getPath(), versionablePath.getString()); } + }