You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2020/09/26 08:46:03 UTC

[jmeter] branch master updated: Guard against empty or wrong threadGroup names

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new dd0d5db  Guard against empty or wrong threadGroup names
dd0d5db is described below

commit dd0d5db7167078c0864a19c4c69c4e8fa8893c54
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sat Sep 26 09:52:21 2020 +0200

    Guard against empty or wrong threadGroup names
    
    JMeter should always set the names correctly, but that may
    not be the case for third-party plugins.
---
 src/core/src/main/java/org/apache/jmeter/samplers/SampleResult.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/samplers/SampleResult.java b/src/core/src/main/java/org/apache/jmeter/samplers/SampleResult.java
index 877f181..0b8867c 100644
--- a/src/core/src/main/java/org/apache/jmeter/samplers/SampleResult.java
+++ b/src/core/src/main/java/org/apache/jmeter/samplers/SampleResult.java
@@ -583,7 +583,9 @@ public class SampleResult implements Serializable, Cloneable, Searchable {
      */
     public String getSampleLabel(boolean includeGroup) {
         if (includeGroup) {
-            return threadName.substring(0, threadName.lastIndexOf(' ')) + ":" + label;
+            // while JMeters own samplers always set the threadName, that might not be the case for plugins
+            int lastSpacePos = Math.max(0, threadName.lastIndexOf(' '));
+            return threadName.substring(0, lastSpacePos) + ":" + label;
         }
         return label;
     }