Commit f2ccd8bc authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Need to account for null values.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3613 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1eea06ba
...@@ -269,7 +269,17 @@ public class Cache<K, V> implements Map<K, V> { ...@@ -269,7 +269,17 @@ public class Cache<K, V> implements Map<K, V> {
} }
public V next() { public V next() {
return it.next().object; if(it.hasNext()) {
CacheObject<V> object = it.next();
if(object == null) {
return null;
} else {
return object.object;
}
}
else {
throw new NoSuchElementException();
}
} }
public void remove() { public void remove() {
...@@ -353,15 +363,34 @@ public class Cache<K, V> implements Map<K, V> { ...@@ -353,15 +363,34 @@ public class Cache<K, V> implements Map<K, V> {
// maximum defined age. // maximum defined age.
deleteExpiredEntries(); deleteExpiredEntries();
int objectSize = calculateSize(value); if(value == null) {
CacheObject cacheObject = new CacheObject(value, objectSize); return containsNullValue();
return map.containsValue(cacheObject); }
Iterator it = values().iterator();
while(it.hasNext()) {
if(value.equals(it.next())) {
return true;
}
}
return false;
}
private boolean containsNullValue() {
Iterator it = values().iterator();
while(it.hasNext()) {
if(it.next() == null) {
return true;
}
}
return false;
} }
public Set entrySet() { public Set entrySet() {
// First, clear all entries that have been in cache longer than the // First, clear all entries that have been in cache longer than the
// maximum defined age. // maximum defined age.
deleteExpiredEntries(); deleteExpiredEntries();
// TODO Make this work right
return Collections.unmodifiableSet(map.entrySet()); return Collections.unmodifiableSet(map.entrySet());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment