Skip to content

feat(core): Add ExceptionUtils.handleFatal to rethrow non-recoverable throwables - #5907

Open
markushi wants to merge 3 commits into
mainfrom
feat/rethrow-fatal-exception-util
Open

feat(core): Add ExceptionUtils.handleFatal to rethrow non-recoverable throwables#5907
markushi wants to merge 3 commits into
mainfrom
feat/rethrow-fatal-exception-util

Conversation

@markushi

@markushi markushi commented Aug 7, 2026

Copy link
Copy Markdown
Member

Summary

Adds ExceptionUtils.handleFatal(Throwable), a small utility for use inside broad catch (Throwable t) blocks. It rethrows VirtualMachineError (e.g. OutOfMemoryError, StackOverflowError) and ThreadDeath as-is, and restores the thread's interrupt flag for InterruptedException instead of swallowing it. All other throwables are left untouched for the caller to handle as before.

Closes #5865

#skip-changelog

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 5cf3e0b

@sentry

sentry Bot commented Aug 7, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.52.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 317.98 ms 357.77 ms 39.79 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
6b019b7 343.31 ms 417.23 ms 73.91 ms
d15471f 286.65 ms 314.68 ms 28.03 ms
d217708 409.83 ms 474.72 ms 64.89 ms
d500866 326.13 ms 378.70 ms 52.58 ms
fcec2f2 314.96 ms 373.66 ms 58.70 ms
d501a7e 314.55 ms 343.34 ms 28.79 ms
7414e9b 322.49 ms 378.88 ms 56.39 ms
fcec2f2 357.47 ms 447.32 ms 89.85 ms
a416a65 316.52 ms 359.67 ms 43.15 ms
983e0f0 350.64 ms 386.44 ms 35.79 ms

App size

Revision Plain With Sentry Diff
6b019b7 0 B 0 B 0 B
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
d217708 1.58 MiB 2.10 MiB 532.97 KiB
d500866 0 B 0 B 0 B
fcec2f2 1.58 MiB 2.12 MiB 551.50 KiB
d501a7e 0 B 0 B 0 B
7414e9b 0 B 0 B 0 B
fcec2f2 1.58 MiB 2.12 MiB 551.50 KiB
a416a65 1.58 MiB 2.12 MiB 555.26 KiB
983e0f0 0 B 0 B 0 B

Previous results on branch: feat/rethrow-fatal-exception-util

Startup times

Revision Plain With Sentry Diff
b65153e 324.29 ms 380.80 ms 56.51 ms

App size

Revision Plain With Sentry Diff
b65153e 0 B 0 B 0 B

Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java
@markushi
markushi marked this pull request as ready for review August 7, 2026 07:33

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice – and thanks for this!

One renaming comment for your consideration, but no blockers 🥇

Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java Outdated
Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java
Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java Outdated

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! It looks good so far.

Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java Outdated
Comment thread sentry/src/main/java/io/sentry/util/ExceptionUtils.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a rethrow function to properly handle non-recoverable Throwables

3 participants