Author: toad
Date: 2006-02-14 14:45:51 +0000 (Tue, 14 Feb 2006)
New Revision: 8042

Modified:
   trunk/freenet/src/freenet/node/Version.java
   trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java
   trunk/freenet/src/freenet/node/fcp/ClientPutMessage.java
   trunk/freenet/src/freenet/support/Fields.java
Log:
447:
Fix nextgens' FCP NPE (which caused e.g. frost inserts to fail).

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-02-14 10:09:24 UTC (rev 
8041)
+++ trunk/freenet/src/freenet/node/Version.java 2006-02-14 14:45:51 UTC (rev 
8042)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 446;
+       private static final int buildNumber = 447;

        /** Oldest build of Fred we will talk to */
        private static final int lastGoodBuild = 403;

Modified: trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java    2006-02-14 
10:09:24 UTC (rev 8041)
+++ trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java    2006-02-14 
14:45:51 UTC (rev 8042)
@@ -7,6 +7,7 @@
 import freenet.keys.FreenetURI;
 import freenet.node.Node;
 import freenet.node.RequestStarter;
+import freenet.support.Fields;
 import freenet.support.SimpleFieldSet;

 /**
@@ -51,16 +52,8 @@

        public ClientGetMessage(SimpleFieldSet fs) throws 
MessageInvalidException {
                short defaultPriority;
-               if(fs.get("IgnoreDS").equalsIgnoreCase("true")){
-                       ignoreDS=true;
-               }else{
-                       ignoreDS=false;
-               }
-               if(fs.get("DSOnly").equalsIgnoreCase("true")){
-                       dsOnly=true;
-               }else{
-                       dsOnly=false;
-               }
+               ignoreDS = Fields.stringToBool(fs.get("IgnoreDS"), false);
+               dsOnly = Fields.stringToBool(fs.get("DSOnly"), false);
                identifier = fs.get("Identifier");
                if(identifier == null)
                        throw new 
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", 
null);

Modified: trunk/freenet/src/freenet/node/fcp/ClientPutMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPutMessage.java    2006-02-14 
10:09:24 UTC (rev 8041)
+++ trunk/freenet/src/freenet/node/fcp/ClientPutMessage.java    2006-02-14 
14:45:51 UTC (rev 8042)
@@ -6,6 +6,7 @@
 import freenet.keys.FreenetURI;
 import freenet.node.Node;
 import freenet.node.RequestStarter;
+import freenet.support.Fields;
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 import freenet.support.io.FileBucket;
@@ -78,11 +79,7 @@
                                throw new 
MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error 
parsing MaxSize field: "+e.getMessage(), identifier);
                        }
                }
-               if(fs.get("GetCHKOnly").equalsIgnoreCase("true")){
-                       getCHKOnly=true;
-               }else{
-                       getCHKOnly=false;
-               }
+               getCHKOnly = Fields.stringToBool(fs.get("GetCHKOnly"), false);
                String priorityString = fs.get("PriorityClass");
                if(priorityString == null) {
                        // defaults to the one just below fproxy
@@ -119,11 +116,7 @@
                                throw new 
MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error 
parsing DataLength field: "+e.getMessage(), identifier);
                        }
                }
-               if(fs.get("DontCompress").equalsIgnoreCase("true")){
-                       dontCompress=true;
-               }else{
-                       dontCompress=false;
-               }
+               dontCompress = Fields.stringToBool(fs.get("DontCompress"), 
false);
        }

        public SimpleFieldSet getFieldSet() {

Modified: trunk/freenet/src/freenet/support/Fields.java
===================================================================
--- trunk/freenet/src/freenet/support/Fields.java       2006-02-14 10:09:24 UTC 
(rev 8041)
+++ trunk/freenet/src/freenet/support/Fields.java       2006-02-14 14:45:51 UTC 
(rev 8042)
@@ -140,8 +140,8 @@
         */
        /* wooo, rocket science! (this is purely abstraction people) */
        public static final boolean stringToBool(String s, boolean def) {
-               return (
-                       def ? !s.equalsIgnoreCase("false") : 
s.equalsIgnoreCase("true"));
+               if(s == null) return def;
+               return (def ? !s.equalsIgnoreCase("false") : 
s.equalsIgnoreCase("true"));
        }

        /**


Reply via email to