Summary: | Adding Include Controller to test plan (made of Include Controllers) without saving TestPlan leads to included code not being taken into account until save | ||
---|---|---|---|
Product: | JMeter | Reporter: | Soul Patch <aviswana> |
Component: | Main | Assignee: | JMeter issues mailing list <issues> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | aviswana, p.mouawad |
Priority: | P2 | ||
Version: | 2.9 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: | proposed patch containing the fix for the issue. |
Description
Soul Patch
2013-07-31 23:54:26 UTC
On Investigation it was found that when traversing the testTree in the initRun() method in JMeterThread.java class the newly added Include Controller is passed as a JMeterTreeNode instead of an IncludeController type. Following is the code flow : JMeterThread.run() --> JMeterThread.initRun() --> Traverses the testTree using the HashTreeTraverser 'compiler'. --> HashTree.traverse() called where the data.keySet() function returns all the keys. The definition of 'data' says : **** // N.B. The keys can be either JMeterTreeNode or TestElement protected final Map<Object, HashTree> data; **** TestCompiler.addNode() called which tries to cast the JMeterTreeNode received to TestElement and a ClassCastException is thrown. Need to investigate why the data.keySet returns a JMeterTreeNode. If it is acceptable then a code should be in place to extract the TestElement from the JMeterTreeNode to avoid the ClassCastException. Found a fix that works well. Don't know if this is the exact fix but it does nothing too radical. Checking for the instance type of the 'node' received. If it is a JMeterTreeNode then extract the TestElement and set it to 'node' and then move ahead. The TestCompiler.addNode() method now looks like this : /** {@inheritDoc} */ @Override public void addNode(Object node, HashTree subTree) { if(node instanceof JMeterTreeNode){ stack.addLast(((JMeterTreeNode)node).getTestElement()); }else{ stack.addLast((TestElement) node); } } Created attachment 30661 [details]
proposed patch containing the fix for the issue.
The patch should be applied to the src/core directory in the source code. It contains the fix for the reported issue. The patch modifies the code in the org.apache.jmeter.threads.TestCompiler.addNode() method.
The method should look like this after adding the patch.
/** {@inheritDoc} */
@Override
public void addNode(Object node, HashTree subTree) {
if(node instanceof JMeterTreeNode){
stack.addLast(((JMeterTreeNode)node).getTestElement());
}else{
stack.addLast((TestElement) node);
}
}
Date: Fri Aug 2 12:02:03 2013 New Revision: 1509647 URL: http://svn.apache.org/r1509647 Log: Bug 55334 - Adding Include Controller to test plan (made of Include Controllers) without saving TestPlan leads to included code not being taken into account until save Bugzilla Id: 55334 Modified: jmeter/trunk/src/core/org/apache/jmeter/JMeter.java jmeter/trunk/xdocs/changes.xml Thanks for patch, but in fact it was not fixing root cause which was due to ReplaceableController not being loaded when in GUI mode and before saving Test Tree. This should be fixed now. Also removed invalid code in o instanceof TestElement branch code: ------------------------------------------------------------ else { // null subTree convertSubTree(tree.getTree(item)); } ------------------------------------------------------------ in this branch, tree.getTree(item) can only be null, so calling convertSubTree would lead to NPE. Thanks for reporting issue. |