jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1430358 - /jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
Date Tue, 08 Jan 2013 16:22:12 GMT
Author: mduerig
Date: Tue Jan  8 16:22:12 2013
New Revision: 1430358

URL: http://svn.apache.org/viewvc?rev=1430358&view=rev
Log:
OAK-543: PutTokenImpl not thread safe
test case demonstrating the issue

Modified:
    jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java

Modified: jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java?rev=1430358&r1=1430357&r2=1430358&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-mk/src/test/java/org/apache/jackrabbit/mk/store/DefaultRevisionStoreTest.java
Tue Jan  8 16:22:12 2013
@@ -16,6 +16,17 @@
  */
 package org.apache.jackrabbit.mk.store;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.jackrabbit.mk.blobs.MemoryBlobStore;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.mk.core.Repository;
@@ -23,6 +34,8 @@ import org.apache.jackrabbit.mk.model.Id
 import org.apache.jackrabbit.mk.model.StoredCommit;
 import org.apache.jackrabbit.mk.persistence.GCPersistence;
 import org.apache.jackrabbit.mk.persistence.InMemPersistence;
+import org.apache.jackrabbit.mk.store.DefaultRevisionStore.PutTokenImpl;
+import org.apache.jackrabbit.mk.store.RevisionStore.PutToken;
 import org.json.simple.JSONArray;
 import org.json.simple.parser.JSONParser;
 import org.junit.After;
@@ -30,10 +43,6 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -190,6 +199,30 @@ public class DefaultRevisionStoreTest {
         }
     }
 
+    @Test
+    @Ignore
+    public void putTokenImpl() throws InterruptedException, ExecutionException {
+        final Set<PutToken> tokens = Collections.synchronizedSet(new HashSet<PutToken>());
+        Set<Future<?>> results = new HashSet<Future<?>>();
+
+        ExecutorService executorService = Executors.newFixedThreadPool(100);
+        for (int i = 0; i < 100; i++) {
+            results.add(executorService.submit(new Callable<Void>() {
+                @Override
+                public Void call() throws Exception {
+                    for (int j = 0; j < 10000; j++) {
+                        assertTrue(tokens.add(new PutTokenImpl()));
+                    }
+                    return null;
+                }
+            }));
+        }
+
+        for (Future<?> result : results) {
+            result.get();
+        }
+    }
+
     /**
      * Parses the provided string into a {@code JSONArray}.
      *



Mime
View raw message