From 0e8f2c83cf84767df7bfbcc02b1d475008d6939e Mon Sep 17 00:00:00 2001 From: David Grieve Date: Wed, 14 Jun 2023 09:45:16 -0400 Subject: [PATCH] fix potential substring(0,0) --- .../java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java b/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java index cc1c834..55b0139 100644 --- a/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java +++ b/parser/src/main/java/com/microsoft/gctoolkit/parser/UnifiedG1GCParser.java @@ -199,7 +199,8 @@ public class UnifiedG1GCParser extends UnifiedGCLogParser implements UnifiedG1GC .findAny() .ifPresentOrElse( tuple -> { - setForwardReference(gcid, line.substring(0, end)); + // Typically, "end" will be greater than zero, but not always. + setForwardReference(gcid, end > 0 ? line.substring(0, end) : line); applyRule(tuple.getKey(), tuple.getValue(), line); }, () -> log(line)