From 7c68d90ef547ecb15af518a5d54c6d24c3dc1385 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Tue, 8 Apr 2025 14:51:38 -0700 Subject: [PATCH] Handle the RegexMatchTimeoutException (#4930) * handle the RegexMatchTimeoutException * Update src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs Co-authored-by: Nick Gallegos --------- Co-authored-by: Nick Gallegos --- ...ptionTypeAndStackTraceFailureClassifier.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs index 3dac69d617..bdb5584c84 100644 --- a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs +++ b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs @@ -1,6 +1,7 @@ namespace ServiceControl.Recoverability { using System.Linq; + using System.Text.RegularExpressions; public class ExceptionTypeAndStackTraceFailureClassifier : IFailureClassifier { @@ -28,21 +29,28 @@ public string ClassifyFailure(ClassifiableMessageDetails failure) // We need to remove the message in order to make sure the stack trace parser does not get into catastrophic backtracking mode. exceptionStackTrace = exceptionStackTrace.Replace(exception.Message, string.Empty); } - - var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame + try { - Type = type, - Method = method, - Params = parameterList, - File = file, - Line = line - }).FirstOrDefault(); + var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame + { + Type = type, + Method = method, + Params = parameterList, + File = file, + Line = line + }).FirstOrDefault(); - if (firstStackTraceFrame != null) + if (firstStackTraceFrame != null) + { + return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier(); + } + } + catch (RegexMatchTimeoutException) { - return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier(); + // Intentionally empty - if the parsing fails, treat it as if exception.Message is null or empty, not throw an exception } + return GetNonStandardClassification(exception.ExceptionType); }