From 7b1218ce83128f77bc23ada202df6f6cf49a84d9 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 cc1c834a..55b01392 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 @@ private void parse(String line) { .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)