[jbosscache-commits] JBoss Cache SVN: r4487 - in core/trunk/src: test/java/org/jboss/cache and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Sep 19 11:23:19 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-09-19 11:23:19 -0400 (Wed, 19 Sep 2007)
New Revision: 4487

Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
   core/trunk/src/test/java/org/jboss/cache/LifeCycleTest.java
Log:
JBCACHE-1179

Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2007-09-19 13:32:27 UTC (rev 4486)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2007-09-19 15:23:19 UTC (rev 4487)
@@ -3968,8 +3968,20 @@
 
       // BR methods should NOT block on the cache being started, since the cache depends on these completing to start.
       if (!MethodDeclarations.isBuddyGroupOrganisationMethod(m.getMethodId()) && !cacheStatus.allowInvocations() && !ctx.getOptionOverrides().isSkipCacheStatusCheck())
-         throw new IllegalStateException("Cache not in STARTED state!");
+      {
+         // only throw an exception if this is a locally originating call - JBCACHE-1179
+         if (originLocal)
+         {
+            throw new IllegalStateException("Cache not in STARTED state!");
+         }
+         else
+         {
+            log.warn("Received a remote call but the cache is not in STARTED state - ignoring call.");
+            return null;
+         }
+      }
 
+
       MethodCall oldCall = null;
       try
       {

Modified: core/trunk/src/test/java/org/jboss/cache/LifeCycleTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/LifeCycleTest.java	2007-09-19 13:32:27 UTC (rev 4486)
+++ core/trunk/src/test/java/org/jboss/cache/LifeCycleTest.java	2007-09-19 15:23:19 UTC (rev 4487)
@@ -17,7 +17,12 @@
 import org.jboss.cache.notifications.annotation.CacheStopped;
 import org.jboss.cache.notifications.event.Event;
 import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.misc.TestingUtil;
 import org.testng.annotations.Test;
+
+import java.util.List;
+import java.util.LinkedList;
+
 /**
  * Tests restart (stop-destroy-create-start) of CacheImpl
  *
@@ -315,13 +320,57 @@
    @SuppressWarnings("unchecked")
    public void testStopInstanceWhileOtherInstanceSends() throws Exception
    {
-      CacheImpl <Object, Object> c[] = new CacheImpl[2];
+      final Fqn fqn = Fqn.fromString("/a");
+      final List<Boolean> running = new LinkedList<Boolean>();
+      final List<Exception> exceptions = new LinkedList<Exception>();
+      running.add(true);
+
+      final CacheImpl <Object, Object> c[] = new CacheImpl[2];
       try
       {
          c[0] = createCache(Configuration.CacheMode.REPL_SYNC);
          c[1] = createCache(Configuration.CacheMode.REPL_SYNC);
+         c[0].start();
+         c[1].start();
+         TestingUtil.blockUntilViewsReceived(5000, c[0], c[1]);
 
-         c[0].put()
+         c[0].put(fqn, "k", "v");
+
+         assert "v".equals(c[0].get(fqn, "k"));
+         assert "v".equals(c[1].get(fqn, "k"));
+
+         // now kick start a thread on c[1] that will constantly update the fqn
+
+         Thread updater = new Thread()
+         {
+            public void run()
+            {
+               int i=0;
+               while (running.get(0))
+               {
+                  try
+                  {
+                     i++;
+                     c[1].put(fqn, "k", "v" + i);
+                  }
+                  catch (Exception e)
+                  {
+                     exceptions.add(e);
+                  }
+                  TestingUtil.sleepThread(20);
+
+               }
+            }
+         };
+
+         updater.start();
+
+         c[0].stop();
+         running.add(false);
+         running.remove(true);
+         updater.join();
+
+         for (Exception e : exceptions) throw e;
       }
       finally
       {




More information about the jbosscache-commits mailing list