mirror of https://github.com/apache/jmeter.git
				
				
				
			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:
		
							parent
							
								
									053dc645ac
								
							
						
					
					
						commit
						9a0e28e169
					
				|  | @ -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} */ | ||||
|  |  | |||
|  | @ -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> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue