Bug 54753

Summary: StringIndexOutOfBoundsException at SampleResult.getSampleLabel() if key_on_threadname=false when using Statistical mode
Product: JMeter - Now in Github Reporter: Danny Lade <dlade>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.9   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Danny Lade 2013-03-26 09:32:02 UTC
Using the StatisticalSampleSender produced always a StringIndexOutOfBoundsException at SampleResult.getSampleLabel().
I found out that the "threadName" is not set if the parameter "keyOnThreadName" at StatisticalSampleResult is false, therefore it is empty and a space can't be found.

IMHO the problem is more based on architecture but on the simple checking if "threadName" is empty (which is in short terms a workaround). Because the current implementation is based on the (hidden) knowledge that the "threadGroup" is part of the "threadName". But this is not always the case, especially on customized sample results.

Either the "treadGroup" should be part of the SampleResult or the sample label should be resolved via SampleEvent instead of SampleResult, if needed.
Comment 1 Sebb 2013-03-26 11:11:10 UTC
Please can you show the full stack trace?
Comment 2 Danny Lade 2013-03-26 14:19:28 UTC
It is rather easy to reproduce - just set following at jmeter.properties:

mode=Statistical
#key_on_threadname=false

Here is the exception:

2013/03/26 15:17:05 ERROR - jmeter.threads.ListenerNotifier: Detected problem in Listener:  java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.substring(Unknown Source)
	at org.apache.jmeter.samplers.SampleResult.getSampleLabel(SampleResult.java:530)
	at org.apache.jmeter.visualizers.SummaryReport.add(SummaryReport.java:165)
	at org.apache.jmeter.reporters.ResultCollector.sendToVisualizer(ResultCollector.java:525)
	at org.apache.jmeter.reporters.ResultCollector.sampleOccurred(ResultCollector.java:501)
	at org.apache.jmeter.samplers.RemoteSampleListenerImpl.processBatch(RemoteSampleListenerImpl.java:96)
	at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
	at sun.rmi.transport.Transport$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
	at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
	at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
	at sun.rmi.server.UnicastRef.invoke(Unknown Source)
	at org.apache.jmeter.samplers.RemoteSampleListenerImpl_Stub.processBatch(Unknown Source)
	at org.apache.jmeter.samplers.StatisticalSampleSender.sendBatch(StatisticalSampleSender.java:197)
	at org.apache.jmeter.samplers.StatisticalSampleSender.sampleOccurred(StatisticalSampleSender.java:184)
	at org.apache.jmeter.samplers.RemoteListenerWrapper.sampleOccurred(RemoteListenerWrapper.java:104)
	at org.apache.jmeter.threads.ListenerNotifier.notifyListeners(ListenerNotifier.java:84)
	at org.apache.jmeter.threads.JMeterThread.notifyListeners(JMeterThread.java:783)
	at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:442)
	at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
	at java.lang.Thread.run(Unknown Source)
Comment 3 Sebb 2013-03-27 00:51:06 UTC
Thanks for the report.

For some reason, the thread name was not being populated in the StatisticalSampleResult if key_on_threadname was false. That has been fixed.

URL: http://svn.apache.org/r1461380
Log:
StringIndexOutOfBoundsException at SampleResult.getSampleLabel() if key_on_threadname=false when using Statistical mode
Bugzilla Id: 5473

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleResult.java
    jmeter/trunk/src/core/org/apache/jmeter/samplers/StatisticalSampleSender.java
    jmeter/trunk/xdocs/changes.xml
Comment 4 The ASF infrastructure team 2022-09-24 20:37:53 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3079