Author: toad
Date: 2008-07-25 23:05:29 +0000 (Fri, 25 Jul 2008)
New Revision: 21410
Modified:
branches/db4o/freenet/src/freenet/support/LRUHashtable.java
Log:
Paranoia - maybe this will be a bit more helpful
Modified: branches/db4o/freenet/src/freenet/support/LRUHashtable.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/LRUHashtable.java 2008-07-25
23:01:15 UTC (rev 21409)
+++ branches/db4o/freenet/src/freenet/support/LRUHashtable.java 2008-07-25
23:05:29 UTC (rev 21410)
@@ -60,7 +60,22 @@
public final synchronized Object peekValue() {
if ( list.size() > 0 ) {
- return ((QItem)hash.get(((QItem)list.tail()).obj)).value;
+ if(hash == null) throw new NullPointerException();
+ QItem tail = (QItem) list.tail();
+ Object object = tail.obj;
+ QItem i = (QItem) hash.get(object);
+ if(i == null) {
+ String obToString = "(toString() threw)";
+ try {
+ obToString = object.toString();
+ } catch (Throwable t) {
+ // Ignore
+ }
+ Logger.error(this, "Lookup failed in LRUHashtable for
"+obToString+" in LRUHashtable - maybe an object was deactivated or its hash
code changed some other way????");
+ return null;
+ }
+ return i.value;
+ //return ((QItem)hash.get(((QItem)list.tail()).obj)).value;
} else {
return null;
}