Bug 61198

Summary: Backend Listener does not work properly in main script when included scripts also contain Backend Listener
Product: JMeter - Now in Github Reporter: taclayto
Component: MainAssignee: JMeter issues mailing list <issues>
Status: VERIFIED FIXED    
Severity: normal CC: emi, p.mouawad
Priority: P2    
Version: 3.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Example JMeter Scripts

Description taclayto 2017-06-19 02:29:31 UTC
Created attachment 35060 [details]
Example JMeter Scripts

***Use Case***
Our testing team makes heavy use of Test Fragments, Include Controllers and Backend Listeners. 

We have a Thread Group in almost every jmx file that we use for testing while developing the Test Fragment. This Thread Group contains a Module Controller and several listeners, one of which is a Backend Listener. 

This Backend Listener in the included jmx file is not a part of the Test Fragment and is scoped only to the Thread Group.

***Defect Description***
Please reference the attached jmx files:
- toBeIncluded.jmx (defines it's samplers in a Test Fragment, has a Thread Group that references the Fragment through a Module Controller) 
- includerScript.jmx (includes toBeIncluded.jmx and defines it's own listeners)

When attempting to run our test from the main .jmx file (either in gui or from cmd line) we see a Null Pointer Exception when the test ends, causing the main process to never stop. 

This is reproducible by running the attached script "includerScript.jmx"

I attempted to trace this behavior through the code and came across the constructor in the BackendListener class.
--------------------------------------------------------
/**
* Create a BackendListener.
*/
public BackendListener() {
  synchronized (LOCK) {
    queuesByTestElementName.clear();
  }
  
  setArguments(new Arguments());
}
--------------------------------------------------------

This constructor is called every time a file is loaded that contains a Backend Listener. I am not familiar enough with the distributed testing feature in JMeter to know why this might be necessary, but looking through the rest of the code, I can't make sense of why this would need to be here.

Commenting out the .clear() command works for the above use case.

***Expected Behavior***
I expect the attached JMeter scripts to work properly. The Backend Listener in the included .jmx file should not affect the main .jmx file's Backend Listener just by virtue of being loaded through JMeter's Save Service.
Comment 1 Philippe Mouawad 2017-07-22 13:52:56 UTC
Author: pmouawad
Date: Sat Jul 22 13:52:34 2017
New Revision: 1802695

URL: http://svn.apache.org/viewvc?rev=1802695&view=rev
Log:
Bug 61198 - Backend Listener does not work properly in main script when included scripts also contain Backend Listener
Bugzilla Id: 61198

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/BackendListener.java
    jmeter/trunk/xdocs/changes.xml
Comment 2 Philippe Mouawad 2017-07-22 13:53:41 UTC
Hello,
Thanks for precise report and analysis.

Issue should be fixed in trunk, can you please next nightly build and confirm issue is fixed in both GUI and NON GUI modes ?

Thanks
Regards
Comment 3 taclayto 2018-01-26 16:40:17 UTC
Hi, works for me on JMeter4.0-SNAPSHOT.20180126

Sorry for taking so long to get around to verifying!
Comment 4 The ASF infrastructure team 2022-09-24 20:38:09 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4414