[jbosscache-commits] JBoss Cache SVN: r5768 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 8 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Apr 30 04:11:48 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-04-30 04:11:48 -0400 (Wed, 30 Apr 2008)
New Revision: 5768

Modified:
   core/trunk/src/main/java/org/jboss/cache/RegionManager.java
   core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java
   core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
   core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
   core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
   core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
   core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
   core/trunk/src/main/java/org/jboss/cache/util/Util.java
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
Log:
TODOs

Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -719,16 +719,14 @@
                // This region's state will no match that of a non-existent one
                // So, there is no reason to keep this region any more
 
-               // FIXME (Brian) We shouldn't do this anymore; now outside code
-               // can have a ref to the region!!
+               // FIXME (Brian) We shouldn't do this anymore; now outside code can have a ref to the region!!
                removeRegion(fqn);
             }
             else
             {
                //region.deactivate();
                region.setActive(false);
-               // FIXME - we should always clean up; otherwise stale data
-               // is in memory!
+               // FIXME - we should always clean up; otherwise stale data is in memory!
                if (cache.getConfiguration().isFetchInMemoryState())
                {
                   inactivateRegion(fqn);
@@ -739,8 +737,7 @@
          {
             region = getRegion(fqn, true);
             region.setActive(false);
-            // FIXME - we should always clean up; otherwise stale data
-            // is in memory!
+            // FIXME - we should always clean up; otherwise stale data is in memory!
             if (cache.getConfiguration().isFetchInMemoryState())
             {
                inactivateRegion(fqn);

Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -558,10 +558,7 @@
          o = cache.getInvocationContext().getOptionOverrides();
          o.setCacheModeLocal(true);
          o.setSkipCacheStatusCheck(true);
-         // FIXME -- restore the next line and remove the following one
-         // when JBCACHE-1265 is fixed
-//         root.addChild(new Fqn<String>(BUDDY_BACKUP_SUBTREE, newGroup.getGroupName()));
-         cache.put(integrationBase, null);
+         cache.getRoot().addChild(Fqn.fromElements(BUDDY_BACKUP_SUBTREE, newGroup.getGroupName()));
       }
       else
       {

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -153,8 +153,6 @@
       notifier.notifyNodeEvicted(fqn, true, ctx);
       n.clearDataDirect();
       n.setDataLoaded(false);
-
-      // FIXME Bela did this so GUI view can refresh the view after node is evicted. But this breaks eviction policy, especially AOP!!!!
       notifier.notifyNodeEvicted(fqn, false, ctx);
    }
 

Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveDataCommand.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -92,7 +92,7 @@
          notifier.notifyNodeVisited(fqn, false, ctx);
       }
       else
-      {// FIXME Bela did this so GUI view can refresh the view after node is evicted. But this breaks eviction policy, especially AOP!!!!
+      {
          if (eviction)
          {
             notifier.notifyNodeEvicted(fqn, false, ctx);

Modified: core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/BuddyReplicationConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -22,6 +22,7 @@
 package org.jboss.cache.config;
 
 import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -139,8 +140,8 @@
                && (this.dataGravitationSearchBackupTrees == other.dataGravitationSearchBackupTrees)
                && (this.enabled == other.enabled)
                && (this.buddyCommunicationTimeout == other.buddyCommunicationTimeout)
-               && safeEquals(this.buddyPoolName, other.buddyPoolName)
-               && safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
+               && Util.safeEquals(this.buddyPoolName, other.buddyPoolName)
+               && Util.safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
       }
 
       return false;
@@ -209,8 +210,8 @@
          if (obj instanceof BuddyLocatorConfig)
          {
             BuddyLocatorConfig other = (BuddyLocatorConfig) obj;
-            return (safeEquals(this.buddyLocatorClass, other.buddyLocatorClass)
-                  && safeEquals(this.buddyLocatorProperties, other.buddyLocatorProperties));
+            return (Util.safeEquals(this.buddyLocatorClass, other.buddyLocatorClass)
+                  && Util.safeEquals(this.buddyLocatorProperties, other.buddyLocatorProperties));
          }
          return false;
       }

Modified: core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/CacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -8,6 +8,7 @@
 
 import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.SingletonStoreCacheLoader;
+import org.jboss.cache.util.Util;
 import org.jboss.cache.xml.XmlHelper;
 
 import java.io.ByteArrayInputStream;
@@ -116,8 +117,8 @@
          CacheLoaderConfig other = (CacheLoaderConfig) obj;
          return (this.passivation == other.passivation)
                && (this.shared == other.shared)
-               && safeEquals(this.preload, other.preload)
-               && safeEquals(this.cacheLoaderConfigs, other.cacheLoaderConfigs);
+               && Util.safeEquals(this.preload, other.preload)
+               && Util.safeEquals(this.cacheLoaderConfigs, other.cacheLoaderConfigs);
       }
       return false;
    }
@@ -321,7 +322,7 @@
             return false;
          IndividualCacheLoaderConfig i = (IndividualCacheLoaderConfig) obj;
          return equalsExcludingProperties(i)
-               && safeEquals(this.properties, i.properties);
+               && Util.safeEquals(this.properties, i.properties);
       }
 
       protected boolean equalsExcludingProperties(Object obj)
@@ -330,11 +331,11 @@
             return false;
          IndividualCacheLoaderConfig other = (IndividualCacheLoaderConfig) obj;
 
-         return safeEquals(this.className, other.className)
+         return Util.safeEquals(this.className, other.className)
                && (this.async == other.async)
                && (this.ignoreModifications == other.ignoreModifications)
                && (this.fetchPersistentState == other.fetchPersistentState)
-               && safeEquals(this.singletonStoreConfig, other.singletonStoreConfig);
+               && Util.safeEquals(this.singletonStoreConfig, other.singletonStoreConfig);
 
       }
 
@@ -454,8 +455,8 @@
             {
                SingletonStoreConfig other = (SingletonStoreConfig) obj;
                return ((this.singletonStoreEnabled == other.singletonStoreEnabled)
-                     && safeEquals(this.singletonStoreClass, other.singletonStoreClass)
-                     && safeEquals(this.singletonStoreproperties, other.singletonStoreproperties));
+                     && Util.safeEquals(this.singletonStoreClass, other.singletonStoreClass)
+                     && Util.safeEquals(this.singletonStoreproperties, other.singletonStoreproperties));
             }
             return false;
          }

Modified: core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/ConfigurationComponent.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -156,14 +156,4 @@
       c.setCache(null);
       return c;
    }
-
-   /**
-    * Null-safe equality test.
-    * <p/>
-    * FIXME this must be written elsewhere.
-    */
-   protected static boolean safeEquals(Object a, Object b)
-   {
-      return (a == b) || (a != null && a.equals(b));
-   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -21,14 +21,12 @@
  */
 package org.jboss.cache.config;
 
-import org.jboss.cache.Fqn;
 import org.jboss.cache.RegionManager;
 import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.cache.util.Util;
 
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 public class EvictionConfig extends ConfigurationComponent
 {
@@ -69,7 +67,7 @@
    public boolean isValidConfig()
    {
       return (defaultEvictionPolicyClass != null && defaultEvictionPolicyClass.length() > 0)
-              || (evictionRegionConfigs != null && evictionRegionConfigs.size() > 0);
+            || (evictionRegionConfigs != null && evictionRegionConfigs.size() > 0);
    }
 
    public String getDefaultEvictionPolicyClass()
@@ -82,22 +80,21 @@
       testImmutability("defaultEvictionPolicyClass");
       this.defaultEvictionPolicyClass = defaultEvictionPolicyClass;
    }
-   
+
    /**
-    * Creates an EvictionRegionConfig for the 
-    * {@link RegionManager.DEFAULT_REGION "_default_"} region using the 
-    * {@link #getDefaultEvictionPolicyClass(String) default eviction policy class}. Throws a 
-    * {@link ConfigurationException} if 
-    * {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class} 
+    * Creates an EvictionRegionConfig for the
+    * {@link RegionManager.DEFAULT_REGION "_default_"} region using the
+    * {@link #getDefaultEvictionPolicyClass(String) default eviction policy class}. Throws a
+    * {@link ConfigurationException} if
+    * {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
     * has not been set.
-    * 
+    *
     * @return an EvictionRegionConfig whose FQN is {@link RegionManager.DEFAULT_REGION}
     *         and whose EvictionPolicyConfig is the default config for the
     *         default eviction policy class.
-    * 
-    * @throws ConfigurationException if a 
-    * {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class} 
-    * has not been set or there is a problem instantiating the configuration.
+    * @throws ConfigurationException if a
+    *                                {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
+    *                                has not been set or there is a problem instantiating the configuration.
     */
    public EvictionRegionConfig createDefaultEvictionRegionConfig()
    {
@@ -128,7 +125,7 @@
    public List<EvictionRegionConfig> getEvictionRegionConfigs()
    {
       if (evictionRegionConfigs == null)
-      {         
+      {
          return new ArrayList<EvictionRegionConfig>(1);
       }
       return evictionRegionConfigs;
@@ -181,8 +178,8 @@
       {
          EvictionConfig other = (EvictionConfig) obj;
          return (this.wakeupIntervalSeconds == other.wakeupIntervalSeconds)
-                 && safeEquals(this.defaultEvictionPolicyClass, other.defaultEvictionPolicyClass)
-                 && safeEquals(this.evictionRegionConfigs, other.evictionRegionConfigs);
+               && Util.safeEquals(this.defaultEvictionPolicyClass, other.defaultEvictionPolicyClass)
+               && Util.safeEquals(this.evictionRegionConfigs, other.evictionRegionConfigs);
       }
       return false;
    }
@@ -206,12 +203,12 @@
          List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>(evictionRegionConfigs.size());
          for (EvictionRegionConfig erc : evictionRegionConfigs)
          {
-             ercs.add(erc.clone());
+            ercs.add(erc.clone());
          }
          clone.setEvictionRegionConfigs(ercs);
       }
       return clone;
    }
-   
-   
+
+
 }

Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionRegionConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -23,6 +23,7 @@
 
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Fqn;
+import org.jboss.cache.util.Util;
 
 import java.lang.reflect.Method;
 
@@ -130,7 +131,7 @@
       if (obj instanceof EvictionRegionConfig)
       {
          EvictionRegionConfig other = (EvictionRegionConfig) obj;
-         return safeEquals(this.regionFqn, other.regionFqn);
+         return Util.safeEquals(this.regionFqn, other.regionFqn);
       }
       return false;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/config/RuntimeConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -9,6 +9,7 @@
 import org.jboss.cache.NodeFactory;
 import org.jboss.cache.RPCManager;
 import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.util.Util;
 import org.jgroups.Channel;
 import org.jgroups.ChannelFactory;
 
@@ -150,10 +151,10 @@
       if (obj instanceof RuntimeConfig)
       {
          RuntimeConfig other = (RuntimeConfig) obj;
-         return safeEquals(transactionManager, other.transactionManager)
-               && safeEquals(muxChannelFactory, other.muxChannelFactory)
-               && safeEquals(rpcManager, other.rpcManager)
-               && safeEquals(channel, other.channel);
+         return Util.safeEquals(transactionManager, other.transactionManager)
+               && Util.safeEquals(muxChannelFactory, other.muxChannelFactory)
+               && Util.safeEquals(rpcManager, other.rpcManager)
+               && Util.safeEquals(channel, other.channel);
       }
 
       return false;

Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictionPolicyConfigBase.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -4,6 +4,7 @@
 import org.jboss.cache.config.ConfigurationException;
 import org.jboss.cache.config.Dynamic;
 import org.jboss.cache.config.EvictionPolicyConfig;
+import org.jboss.cache.util.Util;
 
 /**
  * Base implementation of {@link EvictionPolicyConfig}. Adds properties
@@ -11,13 +12,15 @@
  *
  * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
  */
-public abstract class EvictionPolicyConfigBase 
-   extends ConfigurationComponent
-   implements EvictionPolicyConfig
+public abstract class EvictionPolicyConfigBase
+      extends ConfigurationComponent
+      implements EvictionPolicyConfig
 {
-   /** The serialVersionUID */
+   /**
+    * The serialVersionUID
+    */
    private static final long serialVersionUID = 4591691674370188932L;
-   
+
    private String evictionPolicyClass;
    @Dynamic
    private int maxNodes = 0;
@@ -27,10 +30,10 @@
 
    /**
     * Can only be instantiated by a subclass.
-    * 
+    * <p/>
     * Calls {@link #setEvictionPolicyClassName()}.
     */
-   protected EvictionPolicyConfigBase() 
+   protected EvictionPolicyConfigBase()
    {
       setEvictionPolicyClassName();
    }
@@ -39,7 +42,7 @@
    {
       return evictionPolicyClass;
    }
-   
+
    public void setEvictionPolicyClass(String evictionPolicyClass)
    {
       testImmutability("evictionPolicyClass");
@@ -50,7 +53,7 @@
    {
       return maxNodes;
    }
-   
+
    public void setMaxNodes(int maxNodes)
    {
       testImmutability("maxNodes");
@@ -66,7 +69,7 @@
    {
       this.minTimeToLiveSeconds = minTimeToLiveSeconds;
    }
-   
+
    public void validate() throws ConfigurationException
    {
       // no-op
@@ -77,15 +80,15 @@
    {
       if (this == obj)
          return true;
-      
+
       if (obj instanceof EvictionPolicyConfigBase)
       {
          EvictionPolicyConfigBase other = (EvictionPolicyConfigBase) obj;
-         
+
          return this.maxNodes == other.maxNodes && this.minTimeToLiveSeconds == other.minTimeToLiveSeconds
-                  && safeEquals(this.evictionPolicyClass, other.evictionPolicyClass);
+               && Util.safeEquals(this.evictionPolicyClass, other.evictionPolicyClass);
       }
-      
+
       return false;
    }
 
@@ -98,7 +101,7 @@
       result = 31 * result + (evictionPolicyClass == null ? 0 : evictionPolicyClass.hashCode());
       return result;
    }
-   
+
    public void reset()
    {
       setEvictionPolicyClass(null);

Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -1,6 +1,7 @@
 package org.jboss.cache.loader;
 
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -346,24 +347,24 @@
          AdjListJDBCCacheLoaderConfig other = (AdjListJDBCCacheLoaderConfig) obj;
 
          return (this.createTable == other.createTable)
-               && safeEquals(createTableDDL, other.createTableDDL)
-               && safeEquals(datasourceName, other.datasourceName)
-               && safeEquals(deleteAllSql, other.deleteAllSql)
-               && safeEquals(deleteNodeSql, other.deleteNodeSql)
-               && safeEquals(driverClass, other.driverClass)
+               && Util.safeEquals(createTableDDL, other.createTableDDL)
+               && Util.safeEquals(datasourceName, other.datasourceName)
+               && Util.safeEquals(deleteAllSql, other.deleteAllSql)
+               && Util.safeEquals(deleteNodeSql, other.deleteNodeSql)
+               && Util.safeEquals(driverClass, other.driverClass)
                && (dropTable == other.dropTable)
-               && safeEquals(dropTableDDL, other.dropTableDDL)
-               && safeEquals(insertNodeSql, other.insertNodeSql)
-               && safeEquals(jdbcPassword, other.jdbcPassword)
-               && safeEquals(jdbcURL, other.jdbcURL)
-               && safeEquals(jdbcUser, other.jdbcUser)
-               && safeEquals(selectChildFqnsSql, other.selectChildFqnsSql)
-               && safeEquals(selectChildNamesSql, other.selectChildNamesSql)
-               && safeEquals(selectNodeSql, other.selectNodeSql)
-               && safeEquals(table, other.table)
-               && safeEquals(updateNodeSql, other.updateNodeSql)
-               && safeEquals(updateTableSql, other.updateTableSql)
-               && safeEquals(connectionFactoryClass, other.connectionFactoryClass);
+               && Util.safeEquals(dropTableDDL, other.dropTableDDL)
+               && Util.safeEquals(insertNodeSql, other.insertNodeSql)
+               && Util.safeEquals(jdbcPassword, other.jdbcPassword)
+               && Util.safeEquals(jdbcURL, other.jdbcURL)
+               && Util.safeEquals(jdbcUser, other.jdbcUser)
+               && Util.safeEquals(selectChildFqnsSql, other.selectChildFqnsSql)
+               && Util.safeEquals(selectChildNamesSql, other.selectChildNamesSql)
+               && Util.safeEquals(selectNodeSql, other.selectNodeSql)
+               && Util.safeEquals(table, other.table)
+               && Util.safeEquals(updateNodeSql, other.updateNodeSql)
+               && Util.safeEquals(updateTableSql, other.updateTableSql)
+               && Util.safeEquals(connectionFactoryClass, other.connectionFactoryClass);
       }
 
       return false;

Modified: core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -2,6 +2,7 @@
 
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
 import org.jboss.cache.config.Dynamic;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -69,7 +70,7 @@
    {
       if (obj instanceof FileCacheLoaderConfig && equalsExcludingProperties(obj))
       {
-         return safeEquals(location, ((FileCacheLoaderConfig) obj).location);
+         return Util.safeEquals(location, ((FileCacheLoaderConfig) obj).location);
       }
       return false;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -1,6 +1,7 @@
 package org.jboss.cache.loader;
 
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -126,7 +127,7 @@
       {
          TcpDelegatingCacheLoaderConfig other = (TcpDelegatingCacheLoaderConfig) obj;
 
-         return safeEquals(host, other.host)
+         return Util.safeEquals(host, other.host)
                && (port == other.port) && (timeout == other.timeout) && (reconnectWaitTime == other.reconnectWaitTime);
       }
       return false;

Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -1,6 +1,7 @@
 package org.jboss.cache.loader.bdbje;
 
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -49,7 +50,7 @@
    {
       if (obj instanceof BdbjeCacheLoaderConfig && equalsExcludingProperties(obj))
       {
-         return safeEquals(location, ((BdbjeCacheLoaderConfig) obj).location);
+         return Util.safeEquals(location, ((BdbjeCacheLoaderConfig) obj).location);
       }
       return false;
    }
@@ -65,7 +66,6 @@
    {
       return (BdbjeCacheLoaderConfig) super.clone();
    }
-   
-   
 
+
 }
\ No newline at end of file

Modified: core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -1,6 +1,7 @@
 package org.jboss.cache.loader.jdbm;
 
 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.util.Util;
 
 import java.util.Properties;
 
@@ -49,7 +50,7 @@
    {
       if (obj instanceof JdbmCacheLoaderConfig && equalsExcludingProperties(obj))
       {
-         return safeEquals(location, ((JdbmCacheLoaderConfig) obj).location);
+         return Util.safeEquals(location, ((JdbmCacheLoaderConfig) obj).location);
       }
       return false;
    }

Modified: core/trunk/src/main/java/org/jboss/cache/util/Util.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/Util.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/main/java/org/jboss/cache/util/Util.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -104,6 +104,18 @@
    }
 
    /**
+    * Null-safe equality test.
+    *
+    * @param a first object to compare
+    * @param b second object to compare
+    * @return true if the objects are equals or both null, false otherwise.
+    */
+   public static boolean safeEquals(Object a, Object b)
+   {
+      return (a == b) || (a != null && a.equals(b));
+   }
+
+   /**
     * Static inner class that holds 3 maps - for data added, removed and modified.
     */
    public static class MapModifications

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java	2008-04-30 07:46:37 UTC (rev 5767)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java	2008-04-30 08:11:48 UTC (rev 5768)
@@ -93,8 +93,7 @@
       Fqn fqnA = Fqn.fromString("/a");
       Fqn fqnD = Fqn.fromString("/d");
 
-      // FIXME We have to use a hack to get JBC to recognize that our
-      // regions are for marshalling
+      // FIXME We have to use a hack to get JBC to recognize that our regions are for marshalling
       ClassLoader cl = Fqn.class.getClassLoader();
       caches.get(0).getRegion(fqnA, true).registerContextClassLoader(cl);
       caches.get(1).getRegion(fqnA, true).registerContextClassLoader(cl);




More information about the jbosscache-commits mailing list