in commons-jcs3-core/src/main/java/org/apache/commons/jcs3/engine/memory/AbstractDoubleLinkedListMemoryCache.java [404:477]
private void verifyCache()
{
boolean found = false;
log.trace("verifycache[{0}]: map contains {1} elements, linked list "
+ "contains {2} elements", getCacheName(), map.size(),
list.size());
log.trace("verifycache: checking linked list by key ");
for (MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next)
{
final K key = li.getCacheElement().getKey();
if (!map.containsKey(key))
{
log.error("verifycache[{0}]: map does not contain key : {1}",
getCacheName(), key);
log.error("key class={0}", key.getClass());
log.error("key hashCode={0}", key.hashCode());
log.error("key toString={0}", key.toString());
if (key instanceof GroupAttrName)
{
final GroupAttrName<?> name = (GroupAttrName<?>) key;
log.error("GroupID hashCode={0}", name.groupId.hashCode());
log.error("GroupID.class={0}", name.groupId.getClass());
log.error("AttrName hashCode={0}", name.attrName.hashCode());
log.error("AttrName.class={0}", name.attrName.getClass());
}
dumpMap();
}
else if (map.get(key) == null)
{
log.error("verifycache[{0}]: linked list retrieval returned "
+ "null for key: {1}", getCacheName(), key);
}
}
log.trace("verifycache: checking linked list by value ");
for (MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next)
{
if (!map.containsValue(li))
{
log.error("verifycache[{0}]: map does not contain value: {1}",
getCacheName(), li);
dumpMap();
}
}
log.trace("verifycache: checking via keysets!");
for (final Object val : map.keySet())
{
found = false;
for (MemoryElementDescriptor<K, V> li = list.getFirst(); li != null; li = (MemoryElementDescriptor<K, V>) li.next)
{
if (val.equals(li.getCacheElement().getKey()))
{
found = true;
break;
}
}
if (!found)
{
log.error("verifycache[{0}]: key not found in list : {1}",
getCacheName(), val);
dumpCacheEntries();
if (map.containsKey(val))
{
log.error("verifycache: map contains key");
}
else
{
log.error("verifycache: map does NOT contain key, what the HECK!");
}
}
}
}