Bug 50799 - Having a non-HTTP sampler in a http test plan prevents multiple header managers from working
Having a non-HTTP sampler in a http test plan prevents multiple header manage...
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.4
All All
: P2 normal (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on: 53042
Blocks:
  Show dependency tree
 
Reported: 2011-02-16 11:16 UTC by bernibb
Modified: 2012-04-08 08:00 UTC (History)
1 user (show)



Attachments
testplan demonstrating this issue (8.92 KB, application/octet-stream)
2011-02-16 11:16 UTC, bernibb
Details
Fix proposal (1.74 KB, patch)
2011-11-06 17:11 UTC, Philippe Mouawad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bernibb 2011-02-16 11:16:44 UTC
Created attachment 26671 [details]
testplan demonstrating this issue

Steps to reproduce:
- build up a testplan ass followed (testplan attached) and execute it:
/
|- Test Plan
   |- MyThreadGroup
       |- HttpRequest Sampler 1
       |- Beanshell Sampler
       |- HttpRequest Sampler 2
       |- 2ndLevel HttpHeaderManager
   |- 1stLevel HttpHeaderManager
|- WorkBench

Expected behavior: 
- The header sent by 'HttpRequest Sampler 1' contains the values configured in '1stLevel HttpHeaderManager' and '2ndLevel HttpHeaderManager'
- The header sent by 'HttpRequest Sampler 2' contains the values configured in '1stLevel HttpHeaderManager' and '2ndLevel HttpHeaderManager'

Actual behavior:
- The header sent by 'HttpRequest Sampler 1' contains all expected values
- The header sent by 'HttpRequest Sampler 2' contains only the values configured in '1stLevel HttpHeaderManager'

Notes:
- it seems that the used beanshell sampler prevents the '2ndLevel HttpHeaderManager' from setting its header values to all HttpRequest Samplers which are positioned below/after the beanshell sampler.
- the log file doesn't show any errors or other abnormalities.
- if only one 'http header manager' (it doesn't matter which one in the example mentioned above) is used, the header values are set as expected.
Comment 1 Sebb 2011-03-24 23:33:21 UTC
Does not appear to be anything to do with BeanShell - replacing the BSH sampler with a Java request has the same effect.

However 3 HTTP samplers in succession do work OK.
Comment 2 Philippe Mouawad 2011-11-06 17:11:19 UTC
This issue is due to the following:
JMeterThread#process_sampler calls :
SamplePackage pack = compiler.configureSampler(current);

This calls :
configureWithConfigElements(sampler, pack.getConfigs());
Which ends up calling:
mergeIn()
This methods iterates over HeaderManager properties and adds them to AbstractTestElement as temporary properties but it adds their reference not a clone.


So AbstractTestElement ends up sharing a CollectionProperty with HeaderManager
When sampler.recoverRunningVersion() is called in SamplePackage#recoverRunningVersion(), it calls prop.recoverRunningVersion(this being  AbstractTestElement) 

This calls recoverRunningVersionOfSubElements(this being  AbstractTestElement)
This enters this part of code:
if (owner.isTemporary(prop)) {
   iter.remove();
}
And ends up cleaning HeaderManager collection.


So I think the issue is due to the fact that A CollectionProperty is shared between HeaderManager and AbstractTestElement.

You can see this behaviour by just disabling the 2 HTTP Samplers and keeping only the BeanShellSampler or any other AbstractTestElement except for those who redefined addTestElement (as it's the case for HttpSamplerBase).


I attach a patch (not committed) because I need further advice from Sebb regarding the fix and its impacts.
Comment 3 Philippe Mouawad 2011-11-06 17:11:58 UTC
Created attachment 27902 [details]
Fix proposal
Comment 4 Philippe Mouawad 2011-11-06 20:24:40 UTC
Test Case:
Date: Sun Nov  6 20:18:40 2011
New Revision: 1198547

URL: http://svn.apache.org/viewvc?rev=1198547&view=rev
Log:
Test Case that will fails until BUG 50799 is fixed.

Modified:
   jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java
Comment 5 Philippe Mouawad 2011-11-07 21:22:43 UTC
I wait for your further checks sebb to mark it as fixed.

Date: Mon Nov  7 21:21:26 2011
New Revision: 1198945

URL: http://svn.apache.org/viewvc?rev=1198945&view=rev
Log:
Bug 50799 - Having a non-HTTP sampler in a http test plan prevents multiple header managers from working

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
   jmeter/trunk/test/src/org/apache/jmeter/testelement/PackageTest.java
   jmeter/trunk/xdocs/changes.xml
Comment 6 Philippe Mouawad 2011-11-07 22:10:39 UTC
Date: Mon Nov  7 22:08:15 2011
New Revision: 1198971

URL: http://svn.apache.org/viewvc?rev=1198971&view=rev
Log:
Bug 50799 - Having a non-HTTP sampler in a http test plan prevents multiple header managers from working

The good fix

Modified:
   jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
Comment 7 Philippe Mouawad 2011-11-15 13:13:49 UTC
Fix introduced issue 52187
Comment 8 Philippe Mouawad 2011-11-15 13:23:05 UTC
Date: Tue Nov 15 13:20:20 2011
New Revision: 1202175

URL: http://svn.apache.org/viewvc?rev=1202175&view=rev
Log:
Bug 50799 - Having a non-HTTP sampler in a http test plan prevents multiple header managers from working

Fix ROLLBACK
Comment 9 Philippe Mouawad 2012-04-05 22:05:20 UTC
Date: Thu Apr  5 22:04:43 2012
New Revision: 1310098

URL: http://svn.apache.org/viewvc?rev=1310098&view=rev
Log:
Bug 50799 - Having a non-HTTP sampler in a http test plan prevents multiple header managers from working

Modified:
   jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BSFSampler.java
   jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/BeanShellSampler.java
Comment 10 Philippe Mouawad 2012-04-08 08:00:56 UTC
Fixed by changes done on Bug 53042