Author: sebb
Date: Tue Sep 27 10:48:17 2011
New Revision: 1176320

URL: http://svn.apache.org/viewvc?rev=1176320&view=rev
Log:
Forgot to check if currentSampler had been set to null, e.g. by shutdown

Modified:
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java

Modified: 
jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: 
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1176320&r1=1176319&r2=1176320&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java 
Tue Sep 27 10:48:17 2011
@@ -593,24 +593,25 @@ public class JMeterThread implements Run
 
     /** {@inheritDoc} */
     public boolean interrupt(){
-        Sampler samp = currentSampler; // fetch once
-        if (samp instanceof Interruptible){
-            log.warn("Interrupting: " + threadName + " sampler: " 
+samp.getName());
-            try {
-                interruptLock.lock();
-                samp = currentSampler; // fetch again, to avoid possible lost 
overlap at shutdown
-                boolean found = ((Interruptible)samp).interrupt();
-                if (!found) {
-                    log.warn("No operation pending");
+        try {
+            interruptLock.lock();
+            Sampler samp = currentSampler; // fetch once; must be done under 
lock
+            if (samp instanceof Interruptible){ // (also protects against null)
+                log.warn("Interrupting: " + threadName + " sampler: " 
+samp.getName());
+                try {
+                    boolean found = ((Interruptible)samp).interrupt();
+                    if (!found) {
+                        log.warn("No operation pending");
+                    }
+                    return found;
+                } catch (Exception e) {
+                    log.warn("Caught Exception interrupting sampler: 
"+e.toString());
                 }
-                return found;
-            } catch (Exception e) {
-                log.warn("Caught Exception interrupting sampler: 
"+e.toString());
-            } finally {
-                interruptLock.unlock();
+            } else if (samp != null){
+                log.warn("Sampler is not Interruptible: "+samp.getName());
             }
-        } else if (samp != null){
-            log.warn("Sampler is not Interruptible: "+samp.getName());
+        } finally {
+            interruptLock.unlock();            
         }
         return false;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to