river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1045402 - /incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java
Date Mon, 13 Dec 2010 22:39:49 GMT
Author: peter_firmstone
Date: Mon Dec 13 22:39:49 2010
New Revision: 1045402

URL: http://svn.apache.org/viewvc?rev=1045402&view=rev
Log:
Minor refactoring

Modified:
    incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java

Modified: incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java?rev=1045402&r1=1045401&r2=1045402&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java
(original)
+++ incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java
Mon Dec 13 22:39:49 2010
@@ -126,8 +126,8 @@ public class ConcurrentWeakMap<K, V> imp
 
         @SuppressWarnings("unchecked")
 	static Key create(Object k, ReferenceQueue q) {
-            //if (k == null) {return null;} // Perhaps this is incorrect
-	    if (q == null) {return new Key(k);}
+            if (k == null) throw new IllegalArgumentException("Null key prohibited");
+	    if (q == null) {return new Key(k);} //retrieval key only.
 	    return new Key(k, q);	  
 	}
 	
@@ -140,7 +140,12 @@ public class ConcurrentWeakMap<K, V> imp
 	    super(k, q);
 	    hash = k.hashCode();
 	}
-
+	
+	/* ReferenceQueue is not compared, because a lookup key is used to locate
+	 * an existing key and ReferenceQueue is null in lookup key's.
+	 * 
+	 * ReferenceQueue is not part of hashCode or equals.
+	 */ 
         @Override
 	public boolean equals(Object o) {
 	    if (this == o) return true;
@@ -191,7 +196,7 @@ public class ConcurrentWeakMap<K, V> imp
     public Set<K> keySet() {
         processQueue();
         Enumeration<Key> keys = map.keys(); //Defensive copy by ConcurrentHashMap
-        Set<K> keySet = new HashSet<K>();
+        Set<K> keySet = new HashSet<K>(map.size()); //Optimise resizing
         while (keys.hasMoreElements()){
             keySet.add( (K) keys.nextElement().get());
         }



Mime
View raw message