Author: toad
Date: 2008-10-01 17:03:02 +0000 (Wed, 01 Oct 2008)
New Revision: 22893

Modified:
   branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
Log:
Activation, possible NPE fix, paranoia


Modified: branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java        
2008-10-01 16:11:49 UTC (rev 22892)
+++ branches/db4o/freenet/src/freenet/client/async/SplitFileFetcher.java        
2008-10-01 17:03:02 UTC (rev 22893)
@@ -118,6 +118,8 @@
                this.finished = false;
                this.returnBucket = returnBucket;
                this.fetchContext = newCtx;
+               if(newCtx == null)
+                       throw new NullPointerException();
                this.archiveContext = actx;
                this.decompressors = decompressors2;
                if(decompressors.size() > 1) {
@@ -444,13 +446,25 @@
                        Bucket data = finalStatus(container, context);
                        // Decompress
                        if(persistent) {
-                               container.store(this);
                                container.activate(decompressors, 5);
                                container.activate(returnBucket, 5);
                                cbWasActive = container.ext().isActive(cb);
                                if(!cbWasActive)
                                        container.activate(cb, 1);
                                container.activate(fetchContext, 1);
+                               if(fetchContext == null) {
+                                       Logger.error(this, "Fetch context is 
null");
+                                       
if(!container.ext().isActive(fetchContext)) {
+                                               Logger.error(this, "Fetch 
context is null and splitfile is not activated", new Exception("error"));
+                                               container.activate(this, 1);
+                                               
container.activate(decompressors, 5);
+                                               
container.activate(returnBucket, 5);
+                                               
container.activate(fetchContext, 1);
+                                       } else {
+                                               Logger.error(this, "Fetch 
context is null and splitfile IS activated", new Exception("error"));
+                                       }
+                               }
+                               container.activate(fetchContext, 1);
                        }
                        int count = 0;
                        while(!decompressors.isEmpty()) {
@@ -571,7 +585,8 @@
                                try {
                                        mainBloomFile = 
context.fg.makeRandomFile();
                                        altBloomFile = 
context.fg.makeRandomFile();
-                                       container.store(this);
+                                       if(persistent)
+                                               container.store(this);
                                } catch (IOException e1) {
                                        throw new 
KeyListenerConstructionException(new 
FetchException(FetchException.BUCKET_ERROR, "Unable to create Bloom filter 
files in reconstruction", e1));
                                }


Reply via email to