Bug 63241

Summary: __threadGroupName causes a NullPointerException if called from non Test threads
Product: JMeter Reporter: Kishore Sahadevan <swakaryam>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: major CC: p.mouawad
Priority: P2 Keywords: FixedInTrunk
Version: 4.0   
Target Milestone: JMETER_5.1.1   
Hardware: All   
OS: All   

Description Kishore Sahadevan 2019-03-06 22:07:49 UTC
I have used the __threadGroupName function to name the HTTP Request samplers

eg: ${__threadGroupName}-LC_homepage

Script worked fine and gave the sampler name as expected in the reports.

When I tried a STOP while the script was running for a duration, it gave the below error and continued till the end of the test duration. SHUTDOWN works fine

019-03-06 14:04:49,115 INFO o.a.j.g.a.Start: Stopping test
2019-03-06 14:04:49,133 INFO o.a.j.t.JMeterThread: Stopping: xxxxxxx 1-2
2019-03-06 14:04:49,133 ERROR o.a.j.JMeter: Uncaught exception: 
java.lang.NullPointerException: null
	at org.apache.jmeter.functions.ThreadGroupName.execute(ThreadGroupName.java:54) ~[ApacheJMeter_functions.jar:5.1 r1853635]
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:136) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:111) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:92) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.testelement.AbstractTestElement.getName(AbstractTestElement.java:165) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.threads.JMeterThread.interrupt(JMeterThread.java:808) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.threads.ThreadGroup.stopThread(ThreadGroup.java:359) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.threads.ThreadGroup.lambda$tellThreadsToStop$0(ThreadGroup.java:386) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1597) ~[?:1.8.0_144]
	at org.apache.jmeter.threads.ThreadGroup.tellThreadsToStop(ThreadGroup.java:386) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.threads.ThreadGroup.tellThreadsToStop(ThreadGroup.java:404) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.engine.StandardJMeterEngine$StopTest.tellThreadGroupsToStop(StandardJMeterEngine.java:285) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at org.apache.jmeter.engine.StandardJMeterEngine$StopTest.run(StandardJMeterEngine.java:324) ~[ApacheJMeter_core.jar:5.1 r1853635]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]

thanks
Kishore
Comment 1 Philippe Mouawad 2019-03-09 16:39:07 UTC
Author: pmouawad
Date: Sat Mar  9 16:36:50 2019
New Revision: 1855127

URL: http://svn.apache.org/viewvc?rev=1855127&view=rev
Log:
Bug 63241 - __threadGroupName causes a NullPointerException if called from non Test threads
Bugzilla Id: 63241

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/ThreadGroupName.java
    jmeter/trunk/xdocs/changes.xml
    
Author: pmouawad
Date: Sat Mar  9 16:38:29 2019
New Revision: 1855128

URL: http://svn.apache.org/viewvc?rev=1855128&view=rev
Log:
Bug 63241 - __threadGroupName causes a NullPointerException if called from non Test threads

Add a test
Bugzilla Id: 63241

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/functions/TestSimpleFunctions.java
Comment 2 Philippe Mouawad 2019-03-09 16:50:49 UTC
Author: pmouawad
Date: Sat Mar  9 16:50:28 2019
New Revision: 1855129

URL: http://svn.apache.org/viewvc?rev=1855129&view=rev
Log:
Bug 63241 - __threadGroupName causes a NullPointerException if called from non Test threads

Make test hypothesis clear to avoid failures when tests run in parallel
Bugzilla Id: 63241

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/functions/TestSimpleFunctions.java