Skip to content

Commit 3d8f97d

Browse files
committed
fix: PropertyIterator.remove should remove properties from both collections in TestElement
This is a fixup to a8317d0
1 parent 08e75ec commit 3d8f97d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/core/src/main/java/org/apache/jmeter/testelement/AbstractTestElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public void setProperty(String name, long value, long dflt) {
586586
public PropertyIterator propertyIterator() {
587587
Map<String, JMeterProperty> propMapConcurrent = this.propMapConcurrent;
588588
if (propMapConcurrent != null) {
589-
return new PropertyIteratorImpl(propMapConcurrent.values());
589+
return new PropertyIteratorImpl(this, propMapConcurrent.values());
590590
}
591591

592592
// TODO: copy the contents of the iterator to avoid ConcurrentModificationException?

src/core/src/main/java/org/apache/jmeter/testelement/property/PropertyIteratorImpl.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@
2020
import java.util.Collection;
2121
import java.util.Iterator;
2222

23+
import org.apache.jmeter.testelement.TestElement;
24+
2325
public class PropertyIteratorImpl implements PropertyIterator {
2426

25-
private final Iterator<JMeterProperty> iter;
27+
private final TestElement owner;
28+
private final Iterator<? extends JMeterProperty> iter;
29+
private String lastPropertyName;
2630

2731
public PropertyIteratorImpl(Collection<JMeterProperty> value) {
28-
iter = value.iterator();
32+
this(null, value);
33+
}
34+
35+
public PropertyIteratorImpl(TestElement owner, Iterable<? extends JMeterProperty> properties) {
36+
this.owner = owner;
37+
this.iter = properties.iterator();
2938
}
3039

3140
/** {@inheritDoc} */
@@ -37,13 +46,21 @@ public boolean hasNext() {
3746
/** {@inheritDoc} */
3847
@Override
3948
public JMeterProperty next() {
40-
return iter.next();
49+
JMeterProperty last = iter.next();
50+
if (owner != null) {
51+
lastPropertyName = last.getName();
52+
}
53+
return last;
4154
}
4255

4356
/** {@inheritDoc} */
4457
@Override
4558
public void remove() {
4659
iter.remove();
60+
if (lastPropertyName != null) {
61+
owner.removeProperty(lastPropertyName);
62+
lastPropertyName = null;
63+
}
4764
}
4865

4966
}

0 commit comments

Comments
 (0)