[jbosscache-commits] JBoss Cache SVN: r5421 - core/trunk/src/main/java/org/jboss/cache.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Mar 12 16:25:38 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-03-12 16:25:38 -0400 (Wed, 12 Mar 2008)
New Revision: 5421

Modified:
   core/trunk/src/main/java/org/jboss/cache/RegionManager.java
Log:
Don't throw an exception when there is no default region manager

Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-03-12 14:17:26 UTC (rev 5420)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-03-12 20:25:38 UTC (rev 5421)
@@ -227,14 +227,12 @@
          if (nextFqn.isRoot()) break;
       }
 
-      // test if the default region has been defined.  If not, and if eviction regions
-      // are in use, throw an exception since it is required.
-      if ((nextBestThing == null || nextBestThing.getFqn().isRoot() && !regionsRegistry.containsKey(Fqn.ROOT))
-            && type == EVICTION)
+      // test if the default region has been defined.  If not, and if the request
+      // is for an eviction region, return null
+      if (type == EVICTION && nextBestThing != null && nextBestThing.getFqn().isRoot() && !regionsRegistry.containsKey(Fqn.ROOT))
       {
-         if (log.isTraceEnabled())
-            log.trace("Next best region is " + nextBestThing + ".  RegionsRegistry contains a default? " + regionsRegistry.containsKey(Fqn.ROOT) + " Region type requested = " + type);
-         throw new RuntimeException("No default eviction region defined!");
+         log.trace("No default eviction region; returning null");
+         nextBestThing = null;
       }
 
       return nextBestThing;
@@ -422,7 +420,7 @@
             }
 
             List<Address> members = cache.getMembers();
-            
+
             // Don't bother trying to fetch state if we are in LOCAL mode
             if (members != null && !members.isEmpty())
                rpcManager.fetchPartialState(members, subtreeRoot.getFqn());
@@ -808,12 +806,12 @@
    public void setEvictionConfig(EvictionConfig evictionConfig)
    {
       this.evictionConfig = evictionConfig;
-      
+
       // JBAS-1288
       // Try to establish a default region if there isn't one already
       boolean needDefault = true;
       List<EvictionRegionConfig> ercs = evictionConfig.getEvictionRegionConfigs();
-      
+
       // APPROACH 1: Scan for a default region, try to add if not there.
       // This will try to add the region if it is missing but seems to break 
       // some unit tests that configure one or more non-default regions and
@@ -831,9 +829,9 @@
       // contrary to the idea that there *must* be a default region, but some
       // unit tests fail w/ APPROACH 1, so for now we go with this approach.
       needDefault = ercs.size() == 0;
-      
+
       if (needDefault)
-      {         
+      {
          // This may throw ConfigurationException if there is no default
          // eviction policy class
          EvictionRegionConfig dflt = evictionConfig.createDefaultEvictionRegionConfig();
@@ -842,7 +840,7 @@
          // about the new region
          evictionConfig.setEvictionRegionConfigs(ercs);
       }
-      
+
       // create regions for the regions defined in the evictionConfig.
       // scan to be sure the _default_ region isn't added twice
       boolean setDefault = false;




More information about the jbosscache-commits mailing list