You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2010/12/13 23:39:49 UTC
svn commit: r1045402 -
/incubator/river/jtsk/skunk/pepe/src/org/apache/river/impl/util/ConcurrentWeakMap.java
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());
}