You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2023/05/25 13:01:49 UTC

[jmeter] branch master updated: fix: ensure JMeter still calls recoverRunningVersion for ThreadGroups as it was doing in 5.5

This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new da93b6e857 fix: ensure JMeter still calls recoverRunningVersion for ThreadGroups as it was doing in 5.5
da93b6e857 is described below

commit da93b6e857d9ff2ca2aa4b40678321a81b1d8f36
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Thu May 25 15:59:50 2023 +0300

    fix: ensure JMeter still calls recoverRunningVersion for ThreadGroups as it was doing in 5.5
    
    In fact, ThreadGroup elements are cloned for each thread, so they might need
    recoverRunningVersion.
    
    See https://github.com/apache/jmeter/pull/5920
---
 .../java/org/apache/jmeter/testelement/AbstractTestElement.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java b/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
index 4d1e70e56b..cdff85ef0f 100644
--- a/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
+++ b/src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java
@@ -67,6 +67,10 @@ public abstract class AbstractTestElement implements TestElement, Serializable,
      */
     private transient final ReadWriteLock lock =
             this instanceof NoThreadClone
+                    // Note: thread groups are cloned for every thread, however, JMeterContext contains a reference
+                    // to a non-cloned ThreadGroup instance.
+                    // That causes jmeterContext.getThreadGroup().getName() to access the same ThreadGroup instance
+                    // even though each thread has its own copy, so we use read-write lock approach for ThreadGroups
                     || this instanceof AbstractThreadGroup
                     ? new ReentrantReadWriteLock()
                     : null;
@@ -645,7 +649,7 @@ public abstract class AbstractTestElement implements TestElement, Serializable,
      */
     @Override
     public void recoverRunningVersion() {
-        if (lock != null) {
+        if (this instanceof NoThreadClone) {
             // The element is shared between threads, so there's nothing to recover
             // See https://github.com/apache/jmeter/issues/5875
             return;