jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1352990 - /jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java
Date Fri, 22 Jun 2012 18:11:49 GMT
Author: sebb
Date: Fri Jun 22 18:11:48 2012
New Revision: 1352990

URL: http://svn.apache.org/viewvc?rev=1352990&view=rev
Log:
Avoid NPE when running in non-GUI mode and password has not been provided

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

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java?rev=1352990&r1=1352989&r2=1352990&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/SSLManager.java Fri Jun 22 18:11:48 2012
@@ -155,18 +155,23 @@ public abstract class SSLManager {
             this.defaultpw = System.getProperty(KEY_STORE_PASSWORD);
 
             if (null == defaultpw) {
-                synchronized (this) {
-                    this.defaultpw = JOptionPane.showInputDialog(
-                            GuiPackage.getInstance().getMainFrame(),
-                            JMeterUtils.getResString("ssl_pass_prompt"),  // $NON-NLS-1$
-                            JMeterUtils.getResString("ssl_pass_title"),  // $NON-NLS-1$
-                            JOptionPane.QUESTION_MESSAGE);
-                    System.setProperty(KEY_STORE_PASSWORD, this.defaultpw);
+                final GuiPackage guiInstance = GuiPackage.getInstance();
+                if (guiInstance != null) {
+                    synchronized (this) {
+                        this.defaultpw = JOptionPane.showInputDialog(
+                                guiInstance.getMainFrame(),
+                                JMeterUtils.getResString("ssl_pass_prompt"),  // $NON-NLS-1$
+                                JMeterUtils.getResString("ssl_pass_title"),  // $NON-NLS-1$
+                                JOptionPane.QUESTION_MESSAGE);
+                        System.setProperty(KEY_STORE_PASSWORD, this.defaultpw);
+                    }
+                    password = this.defaultpw;
+                    System.setProperty(KEY_STORE_PASSWORD, password);
+                } else {
+                    log.warn("No password provided, and no GUI present so cannot prompt");
                 }
             }
 
-            password = this.defaultpw;
-            System.setProperty(KEY_STORE_PASSWORD, password);
         }
         return password;
     }



Mime
View raw message