Skip to content

Commit 0cf50f9

Browse files
authored
Do not set the exception group marker when there is a suppressed exception (#4056)
* Do set the exception group marker when there is a suppressed exception * changelog * comment out test assertions for is group flag
1 parent 46f1597 commit 0cf50f9

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Do not set the exception group marker when there is a suppressed exception ([#4056](https://github.com/getsentry/sentry-java/pull/4056))
8+
- Due to how grouping works in Sentry currently sometimes the suppressed exception is treated as the main exception. This change ensures we keep using the main exception and not change how grouping works.
9+
- As a consequence the list of exceptions in the group on top of an issue is no longer shown in Sentry UI.
10+
- We are planning to improve this in the future but opted for this fix first.
11+
512
### Internal
613

714
- Make `SentryClient` constructor public ([#4045](https://github.com/getsentry/sentry-java/pull/4045))

sentry/src/main/java/io/sentry/SentryExceptionFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ Deque<SentryException> extractExceptionQueueInternal(
189189

190190
Throwable[] suppressed = currentThrowable.getSuppressed();
191191
if (suppressed != null && suppressed.length > 0) {
192-
exceptionMechanism.setExceptionGroup(true);
192+
// Disabled for now as it causes grouping in Sentry to sometimes use
193+
// the suppressed exception as main exception.
194+
// exceptionMechanism.setExceptionGroup(true);
193195
for (Throwable suppressedThrowable : suppressed) {
194196
extractExceptionQueueInternal(
195197
suppressedThrowable, exceptionId, circularityDetector, exceptions);

sentry/src/test/java/io/sentry/SentryExceptionFactoryTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class SentryExceptionFactoryTest {
231231

232232
assertEquals("message", mainInQueue.value)
233233
assertEquals(0, mainInQueue.mechanism?.exceptionId)
234-
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
234+
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
235235
}
236236

237237
@Test
@@ -255,12 +255,12 @@ class SentryExceptionFactoryTest {
255255
assertEquals("inner", mainInQueue.value)
256256
assertEquals(1, mainInQueue.mechanism?.exceptionId)
257257
assertEquals(0, mainInQueue.mechanism?.parentId)
258-
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
258+
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
259259

260260
assertEquals("outer", outerInQueue.value)
261261
assertEquals(0, outerInQueue.mechanism?.exceptionId)
262262
assertNull(outerInQueue.mechanism?.parentId)
263-
assertNull(outerInQueue.mechanism?.isExceptionGroup)
263+
// assertNull(outerInQueue.mechanism?.isExceptionGroup)
264264
}
265265

266266
@Test
@@ -288,12 +288,12 @@ class SentryExceptionFactoryTest {
288288
assertEquals("inner", mainInQueue.value)
289289
assertEquals(1, mainInQueue.mechanism?.exceptionId)
290290
assertEquals(0, mainInQueue.mechanism?.parentId)
291-
assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
291+
// assertEquals(true, mainInQueue.mechanism?.isExceptionGroup)
292292

293293
assertEquals("outer", outerInQueue.value)
294294
assertEquals(0, outerInQueue.mechanism?.exceptionId)
295295
assertNull(outerInQueue.mechanism?.parentId)
296-
assertNull(outerInQueue.mechanism?.isExceptionGroup)
296+
// assertNull(outerInQueue.mechanism?.isExceptionGroup)
297297
}
298298

299299
@Test
@@ -324,7 +324,7 @@ class SentryExceptionFactoryTest {
324324
assertEquals("innermost", innerMostExceptionInQueue.value)
325325
assertEquals(3, innerMostExceptionInQueue.mechanism?.exceptionId)
326326
assertEquals(1, innerMostExceptionInQueue.mechanism?.parentId)
327-
assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
327+
// assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
328328

329329
assertEquals("suppressed", innerSuppressedInQueue.value)
330330
assertEquals(2, innerSuppressedInQueue.mechanism?.exceptionId)
@@ -334,7 +334,7 @@ class SentryExceptionFactoryTest {
334334
assertEquals("inner", innerExceptionInQueue.value)
335335
assertEquals(1, innerExceptionInQueue.mechanism?.exceptionId)
336336
assertEquals(0, innerExceptionInQueue.mechanism?.parentId)
337-
assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
337+
// assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
338338

339339
assertEquals("outer", outerInQueue.value)
340340
assertEquals(0, outerInQueue.mechanism?.exceptionId)
@@ -378,7 +378,7 @@ class SentryExceptionFactoryTest {
378378
assertEquals("innermost", innerMostExceptionInQueue.value)
379379
assertEquals(3, innerMostExceptionInQueue.mechanism?.exceptionId)
380380
assertEquals(1, innerMostExceptionInQueue.mechanism?.parentId)
381-
assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
381+
// assertEquals(true, innerMostExceptionInQueue.mechanism?.isExceptionGroup)
382382

383383
assertEquals("suppressed", innerSuppressedInQueue.value)
384384
assertEquals(2, innerSuppressedInQueue.mechanism?.exceptionId)
@@ -388,7 +388,7 @@ class SentryExceptionFactoryTest {
388388
assertEquals("inner", innerExceptionInQueue.value)
389389
assertEquals(1, innerExceptionInQueue.mechanism?.exceptionId)
390390
assertEquals(0, innerExceptionInQueue.mechanism?.parentId)
391-
assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
391+
// assertEquals(true, innerExceptionInQueue.mechanism?.isExceptionGroup)
392392

393393
assertEquals("outer", outerInQueue.value)
394394
assertEquals(0, outerInQueue.mechanism?.exceptionId)

0 commit comments

Comments
 (0)