Skip to content

Commit 194bf61

Browse files
DavidBoikesoujayngallegos
authored
Handle the RegexMatchTimeoutException (#4930) (#4936)
* handle the RegexMatchTimeoutException * Update src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs --------- Co-authored-by: Jayanthi <[email protected]> Co-authored-by: Nick Gallegos <[email protected]>
1 parent 0ac2cca commit 194bf61

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace ServiceControl.Recoverability
22
{
33
using System.Linq;
4+
using System.Text.RegularExpressions;
45

56
public class ExceptionTypeAndStackTraceFailureClassifier : IFailureClassifier
67
{
@@ -28,21 +29,28 @@ public string ClassifyFailure(ClassifiableMessageDetails failure)
2829
// We need to remove the message in order to make sure the stack trace parser does not get into catastrophic backtracking mode.
2930
exceptionStackTrace = exceptionStackTrace.Replace(exception.Message, string.Empty);
3031
}
31-
32-
var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame
32+
try
3333
{
34-
Type = type,
35-
Method = method,
36-
Params = parameterList,
37-
File = file,
38-
Line = line
39-
}).FirstOrDefault();
34+
var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame
35+
{
36+
Type = type,
37+
Method = method,
38+
Params = parameterList,
39+
File = file,
40+
Line = line
41+
}).FirstOrDefault();
4042

41-
if (firstStackTraceFrame != null)
43+
if (firstStackTraceFrame != null)
44+
{
45+
return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier();
46+
}
47+
}
48+
catch (RegexMatchTimeoutException)
4249
{
43-
return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier();
50+
// Intentionally empty - if the parsing fails, treat it as if exception.Message is null or empty, not throw an exception
4451
}
4552

53+
4654
return GetNonStandardClassification(exception.ExceptionType);
4755
}
4856

0 commit comments

Comments
 (0)