Author: nextgens
Date: 2008-07-19 17:10:25 +0000 (Sat, 19 Jul 2008)
New Revision: 21253

Modified:
   trunk/freenet/src/freenet/config/FilePersistentConfig.java
   trunk/freenet/src/freenet/config/PersistentConfig.java
Log:
Fix a sync. problem causing an NPE in the config framework:

juil. 19, 2008 17:08:29:119 (freenet.support.PooledExecutor, Scheduled job: 
freenet.config.FreenetFilePersistentConfig at 9ed91f(13), ERROR): Caught 
java.lang.NullPointerException running job 
freenet.config.FreenetFilePersistentConfig at 9ed91f
java.lang.NullPointerException
        at freenet.config.StringOption.isDefault(StringOption.java:45)
        at freenet.config.SubConfig.exportFieldSet(SubConfig.java:217)
        at 
freenet.config.PersistentConfig.exportFieldSet(PersistentConfig.java:52)
        at 
freenet.config.PersistentConfig.exportFieldSet(PersistentConfig.java:39)
        at 
freenet.config.PersistentConfig.exportFieldSet(PersistentConfig.java:35)
        at 
freenet.config.FilePersistentConfig.innerStore(FilePersistentConfig.java:134)
        at 
freenet.config.FreenetFilePersistentConfig.run(FreenetFilePersistentConfig.java:25)
        at freenet.support.PooledExecutor.run(PooledExecutor.java:186)

Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/FilePersistentConfig.java  2008-07-19 
17:03:45 UTC (rev 21252)
+++ trunk/freenet/src/freenet/config/FilePersistentConfig.java  2008-07-19 
17:10:25 UTC (rev 21253)
@@ -111,11 +111,9 @@
        }

        public void store() {
-               synchronized(this) {
-                       if(!finishedInit) {
-                               Logger.minor(this, "Initialization not 
finished, refusing to write config", new Exception("error"));
-                               return;
-                       }
+               if(!finishedInit) {
+                       Logger.minor(this, "Initialization not finished, 
refusing to write config", new Exception("error"));
+                       return;
                }
                try {
                        synchronized(storeSync) {
@@ -130,7 +128,7 @@
        }

        /** Don't call without taking storeSync first */
-       protected void innerStore() throws IOException {
+       private void innerStore() throws IOException {
                SimpleFieldSet fs = exportFieldSet();
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "fs = " + fs);

Modified: trunk/freenet/src/freenet/config/PersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/PersistentConfig.java      2008-07-19 
17:03:45 UTC (rev 21252)
+++ trunk/freenet/src/freenet/config/PersistentConfig.java      2008-07-19 
17:10:25 UTC (rev 21253)
@@ -11,7 +11,7 @@
 public class PersistentConfig extends Config {

        protected SimpleFieldSet origConfigFileContents;
-       protected boolean finishedInit;
+       protected volatile boolean finishedInit;

        public PersistentConfig(SimpleFieldSet initialContents) {
                this.origConfigFileContents = initialContents;


Reply via email to