You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/12/29 23:36:59 UTC

svn commit: r1776509 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java xdocs/changes.xml

Author: pmouawad
Date: Thu Dec 29 23:36:59 2016
New Revision: 1776509

URL: http://svn.apache.org/viewvc?rev=1776509&view=rev
Log:
Bug 60531 - HTTP Cookie Manager : changing Implementation does not update Cookie Policy
Bugzilla Id: 60531

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java?rev=1776509&r1=1776508&r2=1776509&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/gui/CookiePanel.java Thu Dec 29 23:36:59 2016
@@ -227,21 +227,35 @@ public class CookiePanel extends Abstrac
                 JMeterUtils.reportErrorToUser(ex.getMessage(), "Error saving cookies");
             }
         } else if (action.equals(HANDLER_COMMAND)) {
-            String currentPolicy = policy.getText();
-            policy.setValues(getPolicies(handlerMap.get(selectHandlerPanel.getSelectedItem())));
-            policy.setText(currentPolicy);
+            String cookieHandlerClass = handlerMap.get(selectHandlerPanel.getSelectedItem());
+            CookieHandler handlerImpl = getCookieHandler(cookieHandlerClass);
+            policy.setValues(handlerImpl.getPolicies());
+            policy.setText(handlerImpl.getDefaultPolicy());
          }
     }
 
     /**
+     * @param cookieHandlerClass CookieHandler class name
+     * @return {@link CookieHandler}
+     */
+    private static CookieHandler getCookieHandler(String cookieHandlerClass) {
+        try {
+            CookieHandler cookieHandler = (CookieHandler) 
+                    ClassUtils.getClass(cookieHandlerClass).newInstance();
+            return cookieHandler;
+        } catch (Exception e) {
+            log.error("Error creating implementation:"+cookieHandlerClass+ ", will default to:"+DEFAULT_IMPLEMENTATION, e);
+            return getCookieHandler(DEFAULT_IMPLEMENTATION);
+        }
+    }
+
+    /**
      * @param className CookieHandler class name
      * @return cookie policies
      */
     private static String[] getPolicies(String className) {
         try {
-            CookieHandler cookieHandler = (CookieHandler) 
-                    ClassUtils.getClass(className).newInstance();
-            return cookieHandler.getPolicies();
+            return getCookieHandler(className).getPolicies();
         } catch (Exception e) {
             log.error("Error getting cookie policies from implementation:"+className, e);
             return getPolicies(DEFAULT_IMPLEMENTATION);
@@ -429,9 +443,12 @@ public class CookiePanel extends Abstrac
             if (DEFAULT_IMPLEMENTATION.equals(clazz)) {
                 tmpName = shortClazz;
             }
-            selectHandlerPanel.addItem(shortClazz);
             handlerMap.put(shortClazz, clazz);
         }
+        // Only add to selectHandlerPanel after handlerMap has been initialized
+        for (String shortClazz : handlerMap.keySet()) {
+            selectHandlerPanel.addItem(shortClazz);
+        }
         nodesModel.setSelectedItem(tmpName); // preset to default impl
         return selectHandlerPanel;
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1776509&r1=1776508&r2=1776509&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Thu Dec 29 23:36:59 2016
@@ -154,7 +154,8 @@ Fill in some detail.
 
 <h3>HTTP Samplers and Test Script Recorder</h3>
 <ul>
- </ul>
+    <li><bug>60531</bug>HTTP Cookie Manager : changing Implementation does not update Cookie Policy</li>
+</ul>
 
 <h3>Other Samplers</h3>
 <ul>