Author: sebb
Date: Mon Oct 24 18:26:01 2011
New Revision: 1188277
URL: http://svn.apache.org/viewvc?rev=1188277&view=rev
Log:
Fix bug that was causing Jenkins failures.
Looks like the compiler was converting the input collection to JMeterProperty
then Object.
This did not happen in the iterator case, so the incorrect method parameter
type was not detected.
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java?rev=1188277&r1=1188276&r2=1188277&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
Mon Oct 24 18:26:01 2011
@@ -19,7 +19,6 @@
package org.apache.jmeter.testelement.property;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Map;
import org.apache.jmeter.testelement.TestElement;
@@ -283,27 +282,28 @@ public abstract class AbstractProperty i
}
}
- protected Collection<JMeterProperty>
normalizeList(Collection<JMeterProperty> coll) {
- Iterator<?> iter = coll.iterator();
- Collection<JMeterProperty> newColl = null;
- while (iter.hasNext()) {
- Object item = iter.next();
- if (newColl == null) {
- try {
- @SuppressWarnings("unchecked") // coll is of the correct
type
- final Class<Collection<JMeterProperty>> class1 =
(Class<Collection<JMeterProperty>>) coll.getClass();
- newColl = class1.newInstance();
- } catch (Exception e) {
- log.error("Bad collection", e);
- return coll;
- }
- }
- newColl.add(convertObject(item));
+ /**
+ * Convert a collection of objects into JMeterProperty objects.
+ *
+ * @param coll Collection of any type of object
+ * @return Collection of JMeterProperty objects
+ */
+ protected Collection<JMeterProperty> normalizeList(Collection<?> coll) {
+ if (coll.isEmpty()) {
+ @SuppressWarnings("unchecked") // empty collection
+ Collection<JMeterProperty> okColl = (Collection<JMeterProperty>)
coll;
+ return okColl;
}
- if (newColl != null) {
+ try {
+ @SuppressWarnings("unchecked") // empty collection
+ Collection<JMeterProperty> newColl = coll.getClass().newInstance();
+ for (Object item : coll) {
+ newColl.add(convertObject(item));
+ }
return newColl;
- } else {
- return coll;
+ } catch (Exception e) {// should not happen
+ log.error("Cannot create copy of "+coll.getClass().getName(),e);
+ return null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]