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/29 00:04:36 UTC

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

Author: sebb
Date: Tue Aug 28 22:04:36 2012
New Revision: 1378362

URL: http://svn.apache.org/viewvc?rev=1378362&view=rev
Log:
Remove redundant null check in createJavaClient
Actually use the return value from the method

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=1378362&r1=1378361&r2=1378362&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 22:04:36 2012
@@ -155,7 +155,7 @@ public class JavaSampler extends Abstrac
         context = new JavaSamplerContext(args);
         if (javaClient == null) {
             log.debug(whoAmI() + "\tCreating Java Client");
-            createJavaClient();
+            javaClient = createJavaClient();
             javaClient.setupTest(context);
         }
 
@@ -212,24 +212,23 @@ public class JavaSampler extends Abstrac
      * @return JavaSamplerClient reference.
      */
     private JavaSamplerClient createJavaClient() {
-        if (javaClient == null) {
-            try {
-                Class<?> javaClass = Class.forName(getClassname().trim(), false, Thread.currentThread()
-                        .getContextClassLoader());
-                javaClient = (JavaSamplerClient) javaClass.newInstance();
-
-                if (log.isDebugEnabled()) {
-                    log.debug(whoAmI() + "\tCreated:\t" + getClassname() + "@"
-                            + Integer.toHexString(javaClient.hashCode()));
-                }
-                
-                registerForCleanup(javaClient, context);
-            } catch (Exception e) {
-                log.error(whoAmI() + "\tException creating: " + getClassname(), e);
-                javaClient = new ErrorSamplerClient();
+        JavaSamplerClient client;
+        try {
+            Class<?> javaClass = Class.forName(getClassname().trim(), false, Thread.currentThread()
+                    .getContextClassLoader());
+            client = (JavaSamplerClient) javaClass.newInstance();
+
+            if (log.isDebugEnabled()) {
+                log.debug(whoAmI() + "\tCreated:\t" + getClassname() + "@"
+                        + Integer.toHexString(client.hashCode()));
             }
+            
+            registerForCleanup(client, context);
+        } catch (Exception e) {
+            log.error(whoAmI() + "\tException creating: " + getClassname(), e);
+            client = new ErrorSamplerClient();
         }
-        return javaClient;
+        return client;
     }
 
     /**