Skip to content

Commit b043578

Browse files
authored
Fix exception parsing (#2197)
1 parent bf78a81 commit b043578

File tree

2 files changed

+17
-1
lines changed
  • agent/agent-tooling/src

2 files changed

+17
-1
lines changed

agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/exporter/Exceptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static List<TelemetryExceptionDetails> minimalParse(String str) {
3636
int current;
3737
for (current = 0; current < length; current++) {
3838
char c = str.charAt(current);
39-
if (c == ':') {
39+
if (c == ':' && separator == -1) {
4040
separator = current;
4141
} else if (c == '\r' || c == '\n') {
4242
break;

agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/exporter/ExceptionsTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ void testMinimalParse() {
4747
assertThat(details.getMessage()).isEqualTo("test");
4848
}
4949

50+
@Test
51+
public void testMinimalParseWithColonInMessage() {
52+
// given
53+
String str = toString(new IllegalStateException("hello: world"));
54+
55+
// when
56+
List<TelemetryExceptionDetails> list = Exceptions.minimalParse(str);
57+
58+
// then
59+
assertThat(list.size()).isEqualTo(1);
60+
61+
TelemetryExceptionDetails details = list.get(0);
62+
assertThat(details.getTypeName()).isEqualTo(IllegalStateException.class.getName());
63+
assertThat(details.getMessage()).isEqualTo("hello: world");
64+
}
65+
5066
@Test
5167
void testMinimalParseWithNoMessage() {
5268
// given

0 commit comments

Comments
 (0)