Author: nextgens
Date: 2007-03-03 16:44:39 +0000 (Sat, 03 Mar 2007)
New Revision: 11943

Modified:
   trunk/freenet/src/freenet/config/LongOption.java
Log:
Throw an InvalidConfigValueException if LongOption.setValue can't parse the 
long ... it prevents the node from starting at all if the config. file has been 
badly hand-edited and won't lead to loosing other parts of it (like plugins and 
bookmarks).

it might help issue #1025 : because of such an error, the stun plugin wasn't 
loaded anymore!

Modified: trunk/freenet/src/freenet/config/LongOption.java
===================================================================
--- trunk/freenet/src/freenet/config/LongOption.java    2007-03-03 14:44:36 UTC 
(rev 11942)
+++ trunk/freenet/src/freenet/config/LongOption.java    2007-03-03 16:44:39 UTC 
(rev 11943)
@@ -47,7 +47,12 @@
        }

        public void setValue(String val) throws InvalidConfigValueException {
-               long x = Fields.parseLong(val);
+               long x;
+               try{
+                       x = Fields.parseLong(val);
+               }catch (NumberFormatException e) {
+                       throw new InvalidConfigValueException("The value 
specified can't be parsed : "+val);
+               }
                cb.set(x);
                cachedStringValue = val;
                currentValue = x;
@@ -62,7 +67,12 @@
        }

        public void setInitialValue(String val) throws 
InvalidConfigValueException {
-               long x = Fields.parseLong(val);
+               long x;
+               try{
+                       x = Fields.parseLong(val);
+               }catch (NumberFormatException e) {
+                       throw new InvalidConfigValueException("The value 
specified can't be parsed : "+val);
+               }
                cachedStringValue = val;
                currentValue = x;
        }


Reply via email to