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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Oct 24 10:42:44 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-10-24 10:42:44 -0400 (Wed, 24 Oct 2007)
New Revision: 4680

Modified:
   core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
Log:
Rolled back genman's changes re: MinMapUtil as this was causing breakages

Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2007-10-24 12:45:45 UTC (rev 4679)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java	2007-10-24 14:42:44 UTC (rev 4680)
@@ -14,7 +14,6 @@
 import org.jboss.cache.marshall.MethodDeclarations;
 import org.jboss.cache.optimistic.DataVersion;
 import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.util.MinMapUtil;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -67,10 +66,10 @@
    /**
     * Map of general data keys to values.
     */
-   private Map<K, V> data = Collections.emptyMap();
+   private final Map<K, V> data = new HashMap<K, V>();
 
    private boolean lockForChildInsertRemove;
-   
+
    /**
     * Node moved or removed.
     */
@@ -96,7 +95,7 @@
       init(child_name, fqn, cache);
       setInternalState(data);
    }
-   
+
    /**
     * Initializes with a name and FQN and cache.
     */
@@ -203,13 +202,13 @@
    public Map<K, V> getData()
    {
       assertValid();
-      if (cache == null)
-         return Collections.emptyMap();
+      if (cache == null) return Collections.emptyMap();
       return cache.getData(getFqn());
    }
 
    public Map<K, V> getDataDirect()
    {
+      if (data == null) return Collections.emptyMap();
       return Collections.unmodifiableMap(data);
    }
 
@@ -221,9 +220,7 @@
 
    public V putDirect(K key, V value)
    {
-      V v = data.get(key);
-      data = MinMapUtil.put(data, key, value);
-      return v;
+      return data.put(key, value);
    }
 
    public NodeSPI<K, V> getOrCreateChild(Object child_name, GlobalTransaction gtx)
@@ -296,9 +293,8 @@
 
    public V removeDirect(K key)
    {
-      V v = data.get(key);
-      data = MinMapUtil.remove(data, key);
-      return v;
+      if (data == null) return null;
+      return data.remove(key);
    }
 
    public void printDetails(StringBuffer sb, int indent)
@@ -324,9 +320,12 @@
       {
          sb.append("[ ").append(fqn);
       }
-      synchronized (data)
+      if (data != null)
       {
-         sb.append(" data=").append(data.keySet());
+         synchronized (data)
+         {
+            sb.append(" data=").append(data.keySet());
+         }
       }
       if (children != null && !children.isEmpty())
       {
@@ -390,7 +389,7 @@
 
    public void clearDataDirect()
    {
-      data = Collections.emptyMap();
+      if (data != null) data.clear();
    }
 
    public Node<K, V> getChild(Fqn fqn)
@@ -438,7 +437,7 @@
 
    public Set<K> getKeysDirect()
    {
-      if (data.isEmpty())
+      if (data == null)
       {
          return Collections.emptySet();
       }
@@ -562,7 +561,8 @@
 
    public void putAllDirect(Map<K, V> data)
    {
-      MinMapUtil.putAll(this.data, data);
+      if (data == null) return;
+      this.data.putAll(data);
    }
 
    public void removeChildrenDirect()
@@ -671,8 +671,7 @@
    public Set<Node<K, V>> getChildren()
    {
       assertValid();
-      if (cache == null)
-         return Collections.emptySet();
+      if (cache == null) return Collections.emptySet();
       Set<Node<K, V>> children = new HashSet<Node<K, V>>();
       for (Object c : cache.getChildrenNames(getFqn()))
       {
@@ -801,6 +800,7 @@
       if (onlyInternalState)
          return new HashMap(0);
       // don't bother doing anything here
+      if (data == null) return new HashMap(0);
       return new HashMap(data);
    }
 }




More information about the jbosscache-commits mailing list