Author: sebb
Date: Tue May 22 22:47:05 2012
New Revision: 1341670
URL: http://svn.apache.org/viewvc?rev=1341670&view=rev
Log:
Bug 50898 - IncludeController : NullPointerException loading script in non-GUI
mode if Includers use same element name
Apply better fix that applies for all elements, not just IncludeController
Modified:
jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
jmeter/trunk/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java
Modified:
jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java?rev=1341670&r1=1341669&r2=1341670&view=diff
==============================================================================
---
jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
(original)
+++
jmeter/trunk/src/components/org/apache/jmeter/control/IncludeController.java
Tue May 22 22:47:05 2012
@@ -63,13 +63,6 @@ public class IncludeController extends G
super();
}
- // Bug 50898 - work round the problem just for Include Controllers for now.
- // Can be removed if the AbstractTestElement#equals(Object o) method is
fixed.
- @Override
- public boolean equals(Object obj) {
- return this == obj;
- }
-
@Override
public Object clone() {
// TODO - fix so that this is only called once per test, instead of at
every clone
Modified:
jmeter/trunk/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java?rev=1341670&r1=1341669&r2=1341670&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java
(original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/collections/ListedHashTree.java
Tue May 22 22:47:05 2012
@@ -27,6 +27,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.apache.jorphan.util.JMeterError;
+
/**
* ListedHashTree is a different implementation of the {@link HashTree}
* collection class. In the ListedHashTree, the order in which values are added
@@ -119,7 +121,22 @@ public class ListedHashTree extends Hash
HashTree tree = getTree(currentKey);
data.remove(currentKey);
data.put(newKey, tree);
- order.set(order.indexOf(currentKey), newKey);
+ // find order.indexOf(currentKey) using == rather than equals()
+ // there may be multiple entries which compare equals (Bug 50898)
+ // This will be slightly slower than the built-in method,
+ // but replace() is not used frequently.
+ int entry=-1;
+ for (int i=0; i < order.size(); i++) {
+ Object ent = order.get(i);
+ if (ent == currentKey) {
+ entry = i;
+ break;
+ }
+ }
+ if (entry == -1) {
+ throw new JMeterError("Impossible state, data key not present in
order: "+currentKey.getClass());
+ }
+ order.set(entry, newKey);
}
/** {@inheritDoc} */