Author: nextgens
Date: 2006-12-13 23:17:19 +0000 (Wed, 13 Dec 2006)
New Revision: 11389

Modified:
   trunk/freenet/src/freenet/keys/FreenetURI.java
   trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java
Log:
Prevent a potential NPE in FreenetURI

Modified: trunk/freenet/src/freenet/keys/FreenetURI.java
===================================================================
--- trunk/freenet/src/freenet/keys/FreenetURI.java      2006-12-13 22:59:09 UTC 
(rev 11388)
+++ trunk/freenet/src/freenet/keys/FreenetURI.java      2006-12-13 23:17:19 UTC 
(rev 11389)
@@ -8,7 +8,6 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -724,7 +723,7 @@
                boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                Logger.minor(this, "Getting preferred filename for "+this);
                Vector names = new Vector();
-               if(keyType.equals("KSK") || keyType.equals("SSK")) {
+               if(keyType != null && (keyType.equals("KSK") || 
keyType.equals("SSK"))) {
                        if(logMINOR) Logger.minor(this, "Adding docName: 
"+docName);
                        names.add(docName);
                }

Modified: trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java
===================================================================
--- trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java 2006-12-13 
22:59:09 UTC (rev 11388)
+++ trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java 2006-12-13 
23:17:19 UTC (rev 11389)
@@ -13,6 +13,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
+
 package freenet.crypt;

 import java.math.BigInteger;
@@ -23,7 +24,7 @@
 /**
  * Test case for the {@link freenet.crypt.DSAGroupGeneratorTest} class.
  * 
- * @author Florent Daignière >nextgens at freenetproject.org>
+ * @author Florent Daigni?re >nextgens at freenetproject.org>
  */
 public class DSAGroupGeneratorTest extends TestCase {



Reply via email to