You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/28 22:17:02 UTC

svn commit: r1378293 - /jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java

Author: sebb
Date: Tue Aug 28 20:17:02 2012
New Revision: 1378293

URL: http://svn.apache.org/viewvc?rev=1378293&view=rev
Log:
Simplify; no need to save client and context
Bugzilla Id: 53782

Modified:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java?rev=1378293&r1=1378292&r2=1378293&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java (original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java Tue Aug 28 20:17:02 2012
@@ -84,10 +84,10 @@ public class JavaSampler extends Abstrac
     private static Map<String, Boolean> isToBeRegisteredCache = new ConcurrentHashMap<String, Boolean>();
 
     /**
-     * Set used to register all JavaSamplerClient and JavaSamplerContext. 
+     * Set used to register instances which implement tearDownTest.
      * This is used so that the JavaSamplerClient can be notified when the test ends.
      */
-    private static final Set<Object[]> javaClientAndContextSet = new HashSet<Object[]>();
+    private static final Set<JavaSampler> TEAR_DOWN_SET = new HashSet<JavaSampler>();
 
     /**
      * Create a JavaSampler.
@@ -179,7 +179,7 @@ public class JavaSampler extends Abstrac
     private final void registerForCleanup(JavaSamplerClient jsClient,
             JavaSamplerContext jsContext) throws SecurityException, NoSuchMethodException  {
         if(isToBeRegistered(jsClient.getClass())) {
-            javaClientAndContextSet.add(new Object[]{jsClient, jsContext});
+            TEAR_DOWN_SET.add(this);
         }
     }
 
@@ -278,15 +278,14 @@ public class JavaSampler extends Abstrac
      */
     public void testEnded() {
         log.debug(whoAmI() + "\ttestEnded");
-        synchronized (javaClientAndContextSet) {
-            for (Object[] javaClientAndContext : javaClientAndContextSet) {
-                JavaSamplerClient jsClient = (JavaSamplerClient) javaClientAndContext[0];
-                JavaSamplerContext jsContext = (JavaSamplerContext) javaClientAndContext[1];
-                if (jsClient != null) {
-                    jsClient.teardownTest(jsContext);
+        synchronized (TEAR_DOWN_SET) {
+            for (JavaSampler javaSampler : TEAR_DOWN_SET) {
+                JavaSamplerClient client = javaSampler.javaClient;
+                if (client != null) {
+                    client.teardownTest(javaSampler.context);
                 }
             }
-            javaClientAndContextSet.clear();
+            TEAR_DOWN_SET.clear();
         }
         isToBeRegisteredCache.clear();
     }