From 53b9cb8637c0faddc6b122a1daab72bcc274bdec Mon Sep 17 00:00:00 2001 From: twerth Date: Wed, 6 Apr 2022 01:22:44 -0700 Subject: [PATCH] Catch NumberFormatException while trying to parse thread id. Fixes #14949. PiperOrigin-RevId: 439775241 --- .../com/google/devtools/build/lib/profiler/Profiler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java index c2369e237418b4..9284b70f4210e7 100644 --- a/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java +++ b/src/main/java/com/google/devtools/build/lib/profiler/Profiler.java @@ -1021,7 +1021,14 @@ private static long getSortIndex(String threadName) { return MAX_SORT_INDEX; } - long extractedNumber = Long.parseLong(numberMatcher.group()); + long extractedNumber; + try { + extractedNumber = Long.parseLong(numberMatcher.group()); + } catch (NumberFormatException e) { + // If the number cannot be parsed, e.g. is larger than a long, the actual position is not + // really relevant. + return MAX_SORT_INDEX; + } if (threadName.startsWith("skyframe-evaluator")) { return SKYFRAME_EVALUATOR_SHIFT + extractedNumber;