jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Boston <ianbos...@googlemail.com>
Subject InvalidItemStateException with concurrent threads
Date Thu, 19 Mar 2009 23:07:26 GMT


If I run the test below I reliably get the following exception, any
ideas, what should I be doing that I am not.

This is jackrabbit core 1.4.8

(btw jcrService performs logins into the repository, that has a
BundlePersistanceManager and a ClusterNode configuration, running on
Derby. There is no TransactionManager in this test)



javax.jcr.InvalidItemStateException: e13c3bca-2d00-4717-
af77-02c385b10351/{http://www.sakaiproject.org/CHS/jcr/jackrabbit/
1.0}test has been modified externally
	at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1251)
	at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:897)
	at org.sakaiproject.kernel.util.JcrUtilsT$1.run(JcrUtilsT.java:137)
	at java.lang.Thread.run(Thread.java:613)

   @Test
   public void multiThreadTest() throws Exception {
     Thread[] t = new Thread[20];
     running = 0;
     for (int i = 0; i < t.length; i++) {
       t[i] = new Thread(new Runnable() {

         public void run() {
           running++;
           Random random = new Random();
           try {
             for (int i = 0; i < 20; i++) {
               try {
                 Session session = jcrService.loginSystem();
                 Node node = (Node) session.getItem(randomFile1);
                 try {
                   node.getProperty("sakaijcr:test").remove();
                 } catch (Exception e) {

                 }
                 session.save();
                 Thread.yield();
                 node.setProperty("sakaijcr:test", "new
value"+random.nextLong());
                 session.save();
               } catch (Exception e) {
                 e.printStackTrace();
               } finally {
                 try {
                   jcrService.logout();
                 } catch (Exception e) {
                   e.printStackTrace();
                 }
               }
             }
           } finally {
             running--;
           }
         }

       });
     }
     for (int i = 0; i < t.length; i++) {
       t[i].start();
       Thread.yield();
     }

     while (running > 0) {
       Thread.yield();
     }

   }

Mime
View raw message