[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...

Elias Ross genman at noderunner.net
Mon Nov 20 02:33:14 EST 2006


  User: genman  
  Date: 06/11/20 02:33:14

  Modified:    src/org/jboss/cache/notifications  Notifier.java
  Log:
  JBCACHE-867 -- Fix some data copying issues of Node.getData()
  
  Revision  Changes    Path
  1.10      +16 -6     JBossCache/src/org/jboss/cache/notifications/Notifier.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Notifier.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/notifications/Notifier.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -b -r1.9 -r1.10
  --- Notifier.java	20 Nov 2006 05:09:15 -0000	1.9
  +++ Notifier.java	20 Nov 2006 07:33:14 -0000	1.10
  @@ -6,7 +6,6 @@
    */
   package org.jboss.cache.notifications;
   
  -import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.jboss.cache.CacheListener;
  @@ -16,8 +15,13 @@
   import org.jboss.cache.TreeCache;
   import org.jgroups.View;
   
  +import java.util.concurrent.CopyOnWriteArraySet;
  +import java.util.AbstractMap;
  +import java.util.AbstractSet;
  +import java.util.Arrays;
   import java.util.Collections;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.Map;
   import java.util.Set;
   
  @@ -132,6 +136,13 @@
         restoreInvocationContext();
      }
      
  +   private Map copy(Map data)
  +   {
  +      if (data == null)
  +         throw new NullPointerException();
  +      return Collections.unmodifiableMap(new HashMap(data));
  +   }
  +   
      /**
       * Notifies all registered listeners of a nodeModified event.
       *
  @@ -142,17 +153,16 @@
      public synchronized void notifyNodeModified(Fqn fqn, boolean pre, Map data)
      {
         boolean originLocal = treeCache.getInvocationContext().isOriginLocal();
  -      Map copy = Collections.unmodifiableMap(new HashMap(data));
         resetInvocationContext();
         if (evictionPolicyListener != null)
         {
  -         evictionPolicyListener.nodeModified(fqn, pre, originLocal, copy);
  +         evictionPolicyListener.nodeModified(fqn, pre, originLocal, copy(data));
         }
         if (hasListeners)
         {
            for (CacheListener listener : listeners)
            {
  -            listener.nodeModified(fqn, pre, originLocal, copy);
  +            listener.nodeModified(fqn, pre, originLocal, copy(data));
            }
         }
         restoreInvocationContext();
  @@ -171,13 +181,13 @@
         resetInvocationContext();
         if (evictionPolicyListener != null)
         {
  -         evictionPolicyListener.nodeRemoved(fqn, pre, originLocal, data);
  +         evictionPolicyListener.nodeRemoved(fqn, pre, originLocal, copy(data));
         }
         if (hasListeners)
         {
            for (CacheListener listener : listeners)
            {
  -            listener.nodeRemoved(fqn, pre, originLocal, data);
  +            listener.nodeRemoved(fqn, pre, originLocal, copy(data));
            }
         }
         restoreInvocationContext();
  
  
  



More information about the jboss-cvs-commits mailing list