Author: toad
Date: 2008-10-29 22:46:07 +0000 (Wed, 29 Oct 2008)
New Revision: 23206

Modified:
   branches/db4o/freenet/src/freenet/client/FECJob.java
   branches/db4o/freenet/src/freenet/client/FECQueue.java
   branches/db4o/freenet/src/freenet/client/SplitfileBlock.java
   branches/db4o/freenet/src/freenet/client/async/MinimalSplitfileBlock.java
Log:
Maybe fix NPE in SFFS.onDecodedSegment.


Modified: branches/db4o/freenet/src/freenet/client/FECJob.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FECJob.java        2008-10-29 
22:44:57 UTC (rev 23205)
+++ branches/db4o/freenet/src/freenet/client/FECJob.java        2008-10-29 
22:46:07 UTC (rev 23206)
@@ -119,4 +119,15 @@
                                container.deactivate(checkBlocks[i], 1);
                }
        }
+
+       public void storeBlockStatuses(ObjectContainer container) {
+               if(dataBlockStatus != null) {
+                       for(SplitfileBlock block : dataBlockStatus)
+                               block.storeTo(container);
+               }
+               if(checkBlockStatus != null) {
+                       for(SplitfileBlock block : checkBlockStatus)
+                               block.storeTo(container);
+               }
+       }
 }
\ No newline at end of file

Modified: branches/db4o/freenet/src/freenet/client/FECQueue.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-10-29 
22:44:57 UTC (rev 23205)
+++ branches/db4o/freenet/src/freenet/client/FECQueue.java      2008-10-29 
22:46:07 UTC (rev 23206)
@@ -201,6 +201,7 @@
                                                        
databaseJobRunner.queue(new DBJob() {

                                                                public void 
run(ObjectContainer container, ClientContext context) {
+                                                                       
job.storeBlockStatuses(container);
                                                                        // 
Don't activate the job itself.
                                                                        // It 
MUST already be activated, because it is carrying the status blocks.
                                                                        // The 
status blocks have been set on the FEC thread but *not stored* because

Modified: branches/db4o/freenet/src/freenet/client/SplitfileBlock.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/SplitfileBlock.java        
2008-10-29 22:44:57 UTC (rev 23205)
+++ branches/db4o/freenet/src/freenet/client/SplitfileBlock.java        
2008-10-29 22:46:07 UTC (rev 23206)
@@ -1,5 +1,7 @@
 package freenet.client;

+import com.db4o.ObjectContainer;
+
 import freenet.support.api.Bucket;

 public interface SplitfileBlock {
@@ -16,5 +18,7 @@
        /** Set data */
        abstract void setData(Bucket data);

+       abstract void storeTo(ObjectContainer container);

+
 }

Modified: 
branches/db4o/freenet/src/freenet/client/async/MinimalSplitfileBlock.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/MinimalSplitfileBlock.java   
2008-10-29 22:44:57 UTC (rev 23205)
+++ branches/db4o/freenet/src/freenet/client/async/MinimalSplitfileBlock.java   
2008-10-29 22:46:07 UTC (rev 23206)
@@ -1,6 +1,9 @@
 package freenet.client.async;

+import com.db4o.ObjectContainer;
+
 import freenet.client.SplitfileBlock;
+import freenet.support.Logger;
 import freenet.support.api.Bucket;

 public class MinimalSplitfileBlock implements SplitfileBlock {
@@ -27,5 +30,16 @@
        public void setData(Bucket data) {
                this.data = data;
        }
+       
+       public void objectOnDeactivate(ObjectContainer container) {
+               if(Logger.shouldLog(Logger.MINOR, this))
+                       Logger.minor(this, "Deactivating "+this, new 
Exception("debug"));
+       }

+       public void storeTo(ObjectContainer container) {
+               if(data != null)
+                       data.storeTo(container);
+               container.store(this);
+       }
+
 }


Reply via email to