Bug 63241 - __threadGroupName causes a NullPointerException if called from non Test threads

Bugzilla Id: 63241

git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1855127 13f79535-47bb-0310-9956-ffa450edef68

Former-commit-id: ad2f5a8247
This commit is contained in:
Philippe Mouawad 2019-03-09 16:36:50 +00:00
parent 053dc645ac
commit 9a0e28e169
2 changed files with 9 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.AbstractThreadGroup;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
@ -51,7 +52,13 @@ public class ThreadGroupName extends AbstractFunctionByKey {
} else {
context = JMeterContextService.getContext();
}
return context.getThreadGroup().getName();
AbstractThreadGroup threadGroup = context.getThreadGroup();
if (threadGroup != null) {
return threadGroup.getName();
} else {
// Can happen if called from GUI or from non test threads
return "";
}
}
/** {@inheritDoc} */

View File

@ -154,6 +154,7 @@ Summary
<h3>Functions</h3>
<ul>
<li><bug>63241</bug><code>__threadGroupName</code> causes a NullPointerException if called from non Test threads</li>
</ul>
<h3>I18N</h3>