Author: toad
Date: 2008-07-25 23:40:11 +0000 (Fri, 25 Jul 2008)
New Revision: 21415

Modified:
   branches/db4o/freenet/src/freenet/client/FECQueue.java
Log:
Really fix FECQueue NPEs.

Modified: branches/db4o/freenet/src/freenet/client/FECQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-07-25 
23:22:25 UTC (rev 21414)
+++ branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-07-25 
23:40:11 UTC (rev 21415)
@@ -44,6 +44,7 @@
        private transient int runningFECThreads;
        private transient int fecPoolCounter;
        private transient PrioRunnable runner;
+       private transient DBJob cacheFillerJob;
        private final long nodeDBHandle;

        public static FECQueue create(final long nodeDBHandle, ObjectContainer 
container) {
@@ -56,7 +57,6 @@
                if(result.hasNext()) {
                        FECQueue queue = (FECQueue) result.next();
                        container.activate(queue, 1);
-                       container.activate(queue.cacheFillerJob, 2);
                        return queue;
                } else {
                        FECQueue queue = new FECQueue(nodeDBHandle);
@@ -84,6 +84,7 @@
                }
                OOMHandler.addOOMHook(this);
                initRunner();
+               initCacheFillerJob();
                queueCacheFiller();
        }

@@ -230,7 +231,8 @@
        };
        }

-       private final DBJob cacheFillerJob = new DBJob() {
+       private void initCacheFillerJob() {
+               cacheFillerJob = new DBJob() {

                public void run(ObjectContainer container, ClientContext 
context) {
                        // Try to avoid accessing the database while 
synchronized on the FECQueue.
@@ -308,8 +310,9 @@
                                }
                        }
                }
+               };

-       };
+       }

        private int maxRunningFECThreads = -1;



Reply via email to