jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mat Lowery (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (JCR-3194) ConcurrentModificationException in CacheManager.
Date Fri, 23 Dec 2011 21:26:30 GMT
ConcurrentModificationException in CacheManager.
------------------------------------------------

                 Key: JCR-3194
                 URL: https://issues.apache.org/jira/browse/JCR-3194
             Project: Jackrabbit Content Repository
          Issue Type: Bug
    Affects Versions: 2.3.4
            Reporter: Mat Lowery


Using the test code below, I was able to produce this stack:

java.util.ConcurrentModificationException
	at java.util.WeakHashMap$HashIterator.nextEntry(WeakHashMap.java:762)
	at java.util.WeakHashMap$KeyIterator.next(WeakHashMap.java:795)
	at org.apache.jackrabbit.core.cache.CacheManager.logCacheStats(CacheManager.java:164)
	at org.apache.jackrabbit.core.cache.CacheManager.cacheAccessed(CacheManager.java:137)
	at org.apache.jackrabbit.core.cache.AbstractCache.recordCacheAccess(AbstractCache.java:122)
	at org.apache.jackrabbit.core.cache.ConcurrentCache.get(ConcurrentCache.java:122)
	at org.apache.jackrabbit.core.state.MLRUItemStateCache.retrieve(MLRUItemStateCache.java:71)
	at org.apache.jackrabbit.core.state.ItemStateReferenceCache.retrieve(ItemStateReferenceCache.java:139)
	at org.apache.jackrabbit.core.state.SharedItemStateManager.getNonVirtualItemState(SharedItemStateManager.java:1716)
	at org.apache.jackrabbit.core.state.SharedItemStateManager.getItemState(SharedItemStateManager.java:268)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.getNodeState(LocalItemStateManager.java:110)
	at org.apache.jackrabbit.core.state.LocalItemStateManager.getItemState(LocalItemStateManager.java:175)
	at org.apache.jackrabbit.core.state.XAItemStateManager.getItemState(XAItemStateManager.java:260)
	at org.apache.jackrabbit.core.state.SessionItemStateManager.getItemState(SessionItemStateManager.java:161)
	at org.apache.jackrabbit.core.ItemManager.getItemData(ItemManager.java:382)
	at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:328)
	at org.apache.jackrabbit.core.ItemManager.getItem(ItemManager.java:622)
	at org.apache.jackrabbit.core.ItemManager.getRootNode(ItemManager.java:531)
	at org.apache.jackrabbit.core.SessionImpl.getRootNode(SessionImpl.java:760)
	at test.JackrabbitTest$1.run(JackrabbitTest.java:37)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

-------------------------

package test;

import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.core.TransientRepository;

public class JackrabbitTest {

 public static void main(final String[] args) throws Exception {
   File dir = File.createTempFile("jackrabbit-test", "");
   dir.delete();
   dir.mkdir();
   System.out.println("created temporary directory: " +
       dir.getAbsolutePath());
   dir.deleteOnExit();

   final Repository jcrRepo = new TransientRepository(dir);
   final AtomicBoolean passed = new AtomicBoolean(true);
   final AtomicInteger counter = new AtomicInteger(0);
   ExecutorService executor = Executors.newFixedThreadPool(50);
   Runnable runnable = new Runnable() {

     @Override
     public void run() {
       try {
         Session session = jcrRepo.login(
             new SimpleCredentials("admin",
                 "admin".toCharArray()));
         session.getRootNode().addNode("n" +
                 counter.getAndIncrement()); //unique name
         session.save();
         session.logout();
       } catch (RepositoryException e) {
         e.printStackTrace();
         passed.set(false);
       }
     }

   };
   System.out.println("Running threads");
   for (int i = 0; i<  500; i++) {
     executor.execute(runnable);
   }
   executor.shutdown(); //Disable new tasks from being submitted
   if (!executor.awaitTermination(120, TimeUnit.SECONDS)) {
     System.err.println("timeout");
     System.exit(1);
   }
   if (!passed.get()) {
     System.err.println("one or more threads got an exception");
     System.exit(1);
   } else {
     System.out.println("all threads ran with no exceptions");
     System.exit(0);
   }

 }

}


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message