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/06/04 06:06:43 UTC

[jmeter] branch master updated: fix: wrap recoverRunningVersion with a writeLock

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 209af907f1 fix: wrap recoverRunningVersion with a writeLock
209af907f1 is described below

commit 209af907f1dc477c364c9f6b7edf20f6c9694db1
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Sun Jun 4 09:06:24 2023 +0300

    fix: wrap recoverRunningVersion with a writeLock
    
    Previously, there was no synchronization, however, we'd better hold a write lock
    as we might to modify the properties.
    
    This is a fixup to https://github.com/apache/jmeter/commit/a8317d0fdb563ea7580317b9bd123f0e2797bb48
---
 .../jmeter/testelement/AbstractTestElement.java    | 25 +++++++++++++---------
 1 file changed, 15 insertions(+), 10 deletions(-)

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 c1af18a23b..0e461f809a 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
@@ -654,18 +654,23 @@ public abstract class AbstractTestElement implements TestElement, Serializable,
             // See https://github.com/apache/jmeter/issues/5875
             return;
         }
-        Iterator<Map.Entry<String, JMeterProperty>> iter = propMap.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry<String, JMeterProperty> entry = iter.next();
-            JMeterProperty prop = entry.getValue();
-            if (isTemporary(prop)) {
-                iter.remove();
-                clearTemporary(prop);
-            } else {
-                prop.recoverRunningVersion(this);
+        writeLock();
+        try {
+            Iterator<Map.Entry<String, JMeterProperty>> iter = propMap.entrySet().iterator();
+            while (iter.hasNext()) {
+                Map.Entry<String, JMeterProperty> entry = iter.next();
+                JMeterProperty prop = entry.getValue();
+                if (isTemporary(prop)) {
+                    iter.remove();
+                    clearTemporary(prop);
+                } else {
+                    prop.recoverRunningVersion(this);
+                }
             }
+            emptyTemporary();
+        } finally {
+            writeUnlock();
         }
-        emptyTemporary();
     }
 
     /**