Author: toad
Date: 2008-06-18 19:19:08 +0000 (Wed, 18 Jun 2008)
New Revision: 20453

Modified:
   branches/db4o/freenet/src/freenet/node/NodeClientCore.java
Log:
More init order problems w.r.t. ClientContext causing NPEs

Modified: branches/db4o/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/NodeClientCore.java  2008-06-18 
19:09:19 UTC (rev 20452)
+++ branches/db4o/freenet/src/freenet/node/NodeClientCore.java  2008-06-18 
19:19:08 UTC (rev 20453)
@@ -167,10 +167,23 @@
                if(logMINOR) Logger.minor(this, "Read 
throttleFS:\n"+throttleFS);

                if(logMINOR) Logger.minor(this, "Serializing 
RequestStarterGroup from:\n"+throttleFS);
-               clientContext = new ClientContext(this);
-               requestStarters = new RequestStarterGroup(node, this, 
portNumber, random, config, throttleFS, clientContext);
-               clientContext.init(requestStarters);

+               tempDir = new File(nodeConfig.getString("tempDir"));
+               if(!((tempDir.exists() && tempDir.isDirectory()) || 
(tempDir.mkdir()))) {
+                       String msg = "Could not find or create temporary 
directory";
+                       throw new 
NodeInitException(NodeInitException.EXIT_BAD_TEMP_DIR, msg);
+               }
+               
+               try {
+                       tempFilenameGenerator = new FilenameGenerator(random, 
true, tempDir, "temp-");
+               } catch (IOException e) {
+                       String msg = "Could not find or create temporary 
directory (filename generator)";
+                       throw new 
NodeInitException(NodeInitException.EXIT_BAD_TEMP_DIR, msg);
+               }
+
+               archiveManager = new ArchiveManager(MAX_ARCHIVE_HANDLERS, 
MAX_CACHED_ARCHIVE_DATA, MAX_ARCHIVE_SIZE, MAX_ARCHIVED_FILE_SIZE, 
MAX_CACHED_ELEMENTS, random, node.fastWeakRandom, tempFilenameGenerator);
+               uskManager = new USKManager(this);
+               
                // Temp files

                nodeConfig.register("tempDir", new File(nodeDir, 
"temp-"+portNumber).toString(), sortOrder++, true, true, 
"NodeClientCore.tempDir", "NodeClientCore.tempDirLong", 
@@ -185,19 +198,6 @@
                                        }
                });

-               tempDir = new File(nodeConfig.getString("tempDir"));
-               if(!((tempDir.exists() && tempDir.isDirectory()) || 
(tempDir.mkdir()))) {
-                       String msg = "Could not find or create temporary 
directory";
-                       throw new 
NodeInitException(NodeInitException.EXIT_BAD_TEMP_DIR, msg);
-               }
-               
-               try {
-                       tempFilenameGenerator = new FilenameGenerator(random, 
true, tempDir, "temp-");
-               } catch (IOException e) {
-                       String msg = "Could not find or create temporary 
directory (filename generator)";
-                       throw new 
NodeInitException(NodeInitException.EXIT_BAD_TEMP_DIR, msg);
-               }
-
                // Persistent temp files
                nodeConfig.register("persistentTempDir", new File(nodeDir, 
"persistent-temp-"+portNumber).toString(), sortOrder++, true, false, 
"NodeClientCore.persistentTempDir", "NodeClientCore.persistentTempDirLong",
                                new StringCallback() {
@@ -221,6 +221,10 @@

                tempBucketFactory = new 
PaddedEphemerallyEncryptedBucketFactory(new 
TempBucketFactory(tempFilenameGenerator), random, node.fastWeakRandom, 1024);

+               clientContext = new ClientContext(this);
+               requestStarters = new RequestStarterGroup(node, this, 
portNumber, random, config, throttleFS, clientContext);
+               clientContext.init(requestStarters);
+               
                // Downloads directory

                nodeConfig.register("downloadsDir", "downloads", sortOrder++, 
true, true, "NodeClientCore.downloadDir", "NodeClientCore.downloadDirLong", new 
StringCallback() {
@@ -294,10 +298,8 @@
                });
                
setUploadAllowedDirs(nodeConfig.getStringArr("uploadAllowedDirs"));

-               archiveManager = new ArchiveManager(MAX_ARCHIVE_HANDLERS, 
MAX_CACHED_ARCHIVE_DATA, MAX_ARCHIVE_SIZE, MAX_ARCHIVED_FILE_SIZE, 
MAX_CACHED_ELEMENTS, random, node.fastWeakRandom, tempFilenameGenerator);
                Logger.normal(this, "Initializing USK Manager");
                System.out.println("Initializing USK Manager");
-               uskManager = new USKManager(this);
                uskManager.init(container, clientContext);

                healingQueue = new 
SimpleHealingQueue(requestStarters.chkPutScheduler,


Reply via email to