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,16 @@ */ 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.security.AccessControlEntry; import javax.jcr.security.AccessControlList; import javax.jcr.security.Privilege; @@ -28,6 +33,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 +325,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 VersionHistory vHistory; + private final String vName; + + public Worker(String vPath) throws RepositoryException { + VersionManager versionManager = getHelper().getSuperuserSession().getWorkspace().getVersionManager(); + Version version = versionManager.checkin(vPath); + versionManager.checkout(vPath); + vHistory = version.getContainingHistory(); + vName = version.getName(); + } + + @Override + public Void call() throws Exception { + for (int k = 0; k < 1000; k++) { + try { + String label = k + " " + Thread.currentThread().getName(); + System.out.println(label); + vHistory.addVersionLabel(vName, label, true); + } catch (RepositoryException ignore) { } + } + return null; + } + } + /** * @since oak */ @@ -403,4 +455,5 @@ Property versionablePath = vh.getProperty(superuser.getWorkspace().getName()); assertEquals(testNode.getPath(), versionablePath.getString()); } + }