Author: toad
Date: 2008-06-20 22:26:52 +0000 (Fri, 20 Jun 2008)
New Revision: 20541

Modified:
   branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
Log:
Finally fix the no HashSet for xxx bug.
We were putting using ClientRequester's as keys in a HashMap, without defining 
hashCode(). That doesn't work with persistent objects.

Modified: branches/db4o/freenet/src/freenet/client/async/ClientRequester.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientRequester.java 
2008-06-20 22:26:01 UTC (rev 20540)
+++ branches/db4o/freenet/src/freenet/client/async/ClientRequester.java 
2008-06-20 22:26:52 UTC (rev 20541)
@@ -30,6 +30,7 @@
        protected ClientRequester(short priorityClass, RequestClient client) {
                this.priorityClass = priorityClass;
                this.client = client;
+               hashCode = super.hashCode(); // the old object id will do fine, 
as long as we ensure it doesn't change!
        }

        public synchronized void cancel() {
@@ -43,6 +44,15 @@
        public abstract FreenetURI getURI();

        public abstract boolean isFinished();
+       
+       private final int hashCode;
+       
+       /**
+        * We need a hash code that persists across restarts.
+        */
+       public int hashCode() {
+               return hashCode;
+       }

        /** Total number of blocks this request has tried to fetch/put. */
        protected int totalBlocks;


Reply via email to