3 Replies Latest reply on Oct 29, 2004 3:59 AM by Bela Ban

    potential issue in cache interceptors

    visionlink Newbie

      each of CacheLoaderInterceptor, ReplicationInterceptor, and TransactionInterceptor has a list of transactions for which they have been registered. after transaction completion, the transactions are not removed from the list, so the lists grow without bound. since these interceptors use List.contains, the lookups are linear, so you can see this problem manifest itself with the following program:

      import org.jboss.cache.TreeCache;
      import org.jboss.cache.DummyTransactionManagerLookup;
      import org.jboss.cache.transaction.DummyUserTransaction;
      import org.jboss.cache.transaction.DummyTransactionManager;
      import javax.transaction.UserTransaction;
      
      public class foo
      {
       public static void main(String[] argv)
       throws Exception
       {
       TreeCache tc;
       UserTransaction tx;
      
       tc = new TreeCache();
       tc.setTransactionManagerLookup(new DummyTransactionManagerLookup());
       tc.start();
      
       tx = new DummyUserTransaction(DummyTransactionManager.getInstance());
       tx.begin();
       tc.put("/foo/1", "item", new Integer(1));
       tx.commit();
      
       while (true)
       {
       long start = System.currentTimeMillis();
       for (int i = 0; i < 100; i++)
       {
       tx = new DummyUserTransaction(DummyTransactionManager.getInstance());
       tx.begin();
       tc.get("/foo/1", "item");
       tx.commit();
       }
       long stop = System.currentTimeMillis();
       System.out.println("took: " + (stop - start));
       }
       }
      }