|
20 | 20 | import java.io.Serializable; |
21 | 21 | import java.util.ArrayList; |
22 | 22 | import java.util.Collections; |
23 | | -import java.util.Iterator; |
24 | 23 | import java.util.LinkedHashMap; |
25 | 24 | import java.util.LinkedHashSet; |
26 | 25 | import java.util.List; |
@@ -654,18 +653,29 @@ public void recoverRunningVersion() { |
654 | 653 | // See https://github.com/apache/jmeter/issues/5875 |
655 | 654 | return; |
656 | 655 | } |
657 | | - Iterator<Map.Entry<String, JMeterProperty>> iter = propMap.entrySet().iterator(); |
658 | | - while (iter.hasNext()) { |
659 | | - Map.Entry<String, JMeterProperty> entry = iter.next(); |
660 | | - JMeterProperty prop = entry.getValue(); |
661 | | - if (isTemporary(prop)) { |
662 | | - iter.remove(); |
663 | | - clearTemporary(prop); |
664 | | - } else { |
| 656 | + writeLock(); |
| 657 | + try { |
| 658 | + Set<JMeterProperty> tempProperties = temporaryProperties; |
| 659 | + // Remove temporary properties first |
| 660 | + if (tempProperties != null) { |
| 661 | + for (JMeterProperty prop : tempProperties) { |
| 662 | + removeProperty(prop.getName()); |
| 663 | + } |
| 664 | + } |
| 665 | + // Recover non-temporary properties |
| 666 | + for (JMeterProperty prop : propMap.values()) { |
665 | 667 | prop.recoverRunningVersion(this); |
666 | 668 | } |
| 669 | + // Clearing the temporary properties must happen after we recover all the other properties |
| 670 | + // The reason is that some of the properties might be MultiProperty which uses |
| 671 | + // testElement.temporaryProperties storage instead of tracking the temps on its own |
| 672 | + // TODO: move temp tracking to MultiProperty |
| 673 | + if (tempProperties != null) { |
| 674 | + tempProperties.clear(); |
| 675 | + } |
| 676 | + } finally { |
| 677 | + writeUnlock(); |
667 | 678 | } |
668 | | - emptyTemporary(); |
669 | 679 | } |
670 | 680 |
|
671 | 681 | /** |
|
0 commit comments