jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1352988 - /jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java
Date Fri, 22 Jun 2012 18:10:21 GMT
Author: sebb
Date: Fri Jun 22 18:10:20 2012
New Revision: 1352988

URL: http://svn.apache.org/viewvc?rev=1352988&view=rev
Log:
Avoid NPE when password is not provided

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java?rev=1352988&r1=1352987&r2=1352988&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java Fri Jun 22 18:10:20
2012
@@ -44,7 +44,7 @@ public class JmeterKeyStore {
 
     private X509Certificate[][] certChains;
     private PrivateKey[] keys;
-    private String[] names;
+    private String[] names = new String[0]; // default empty array to prevent NPEs
 
     //@GuardedBy("this")
     private int last_user;
@@ -62,7 +62,8 @@ public class JmeterKeyStore {
      * Process the input stream
      */
     public void load(InputStream is, String pword) throws Exception {
-        store.load(is, pword.toCharArray());
+        char pw[] = pword==null ? null : pword.toCharArray();
+        store.load(is, pw);
     
         ArrayList<String> v_names = new ArrayList<String>();
         ArrayList<PrivateKey> v_keys = new ArrayList<PrivateKey>();
@@ -76,7 +77,7 @@ public class JmeterKeyStore {
                 String alias = aliases.nextElement();
                 if (store.isKeyEntry(alias)) {
                     if ((index >= startIndex && index <= endIndex)) {
-                        _key = (PrivateKey) store.getKey(alias, pword.toCharArray());
+                        _key = (PrivateKey) store.getKey(alias, pw);
                         if (null == _key) {
                             throw new Exception("No key found for alias: " + alias); // Should
not happen
                         }



Mime
View raw message