Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem parsing exceptions if message contains ':' #2196

Closed
pybalo opened this issue Mar 17, 2022 · 1 comment · Fixed by #2197
Closed

Problem parsing exceptions if message contains ':' #2196

pybalo opened this issue Mar 17, 2022 · 1 comment · Fixed by #2197

Comments

@pybalo
Copy link

pybalo commented Mar 17, 2022

The TypeName in TelemetryExceptionDetails should be what is at the left side of first semicolon in the first line of the stack trace.
If the exception message contains colons, the parsing is wrong. E.g: Given the folowing stack trace

org.example.MyCustomException: Invalid character ':' Don't use colons!
	at org.example.code1(example1.java:42)
	at org.example.code2(example2.java:42)

Expected behavior

TypeName = "org.example.MyCustomException"
Mesage = "Invalid character ':' Don't use colons!"

Actual behavior

TypeName = "org.example.MyCustomException: Invalid character '"
Mesage = "' Don't use colons!"

Suggested patch

diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exceptions.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exceptions.java
index fcdbbe5908..91d2bbd8d7 100644
--- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exceptions.java
+++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exceptions.java
@@ -36,7 +36,7 @@ public class Exceptions {
     int current;
     for (current = 0; current < length; current++) {
       char c = str.charAt(current);
-      if (c == ':') {
+      if (c == ':' && separator != -1) {
         separator = current;
       } else if (c == '\r' || c == '\n') {
         break;
@trask
Copy link
Member

trask commented Mar 17, 2022

thx @pybalo! I sent #2197 with your fix!

@ghost ghost added the Status: Fixed label Mar 17, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants