Repository navigation
fix: Rethrow fatal errors at the SDK's boundary catches (JAVA-552) - #6665
runningcode wants to merge 5 commits into
Conversation
The broad catches at boundaries, where we can't know what the other side throws, also swallowed OutOfMemoryError, StackOverflowError and LinkageError. They now call ExceptionUtils.rethrowIfFatal first, with a comment saying why the catch is broad and what is lost when it fails. The Javadoc of the user-facing callbacks says what happens when they throw. Sites where a LinkageError is the expected failure are left alone, so a missing or mismatched optional dependency keeps the old handling. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🚨 Detected changes in high risk code 🚨High-risk code has higher potential to break the SDK and may be hard to test. To prevent severe bugs, apply the rollout process for releasing such changes and be extra careful when changing and reviewing these files:
|
📲 Install BuildsAndroid
|
Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Narrowing attachReportToEnvelope to IOException is a narrowing, not a boundary, so it moves to the PR that narrows catches. Refs #5513 Refs JAVA-552 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d79261d. Configure here.
| * <p>If a processor throws, the event is dropped and the exception is logged at {@link | ||
| * SentryLevel#ERROR} through {@link SentryOptions#getLogger()}, which by default prints only when | ||
| * {@link SentryOptions#isDebug()} is enabled. Fatal errors, such as {@link OutOfMemoryError}, are | ||
| * rethrown. |
There was a problem hiding this comment.
EventProcessor fatals still swallowed
Medium Severity
The new EventProcessor Javadoc says fatal errors such as OutOfMemoryError are rethrown, but SentryClient.processEvent, processTransaction, processLogEvent, and processMetricsEvent still catch Throwable without ExceptionUtils.rethrowIfFatal. A fatal from a user processor is logged (only with debug) and the event is dropped, which is the swallow this PR set out to stop.
Additional Locations (2)
Triggered by project rule: PR Review Guidelines for Cursor Bugbot
Reviewed by Cursor Bugbot for commit d79261d. Configure here.
| * {@link OutOfMemoryError} are rethrown instead. The skipped integration is only reported as a | ||
| * warning through {@link SentryOptions#getLogger()}, which by default prints only when {@link | ||
| * SentryOptions#isDebug()} is enabled. To find out whether your integration registered, enable | ||
| * debug and look for "Failed to register the integration" in the log. |
There was a problem hiding this comment.
Integration register fatals still swallowed
Medium Severity
The new Integration.register Javadoc says fatal errors such as OutOfMemoryError are rethrown from Sentry.init, but the catch (Throwable) around integration.register(...) still only logs a warning. Init keeps going after a fatal, so a crashing integration is skipped with no visible failure unless debug is on.
Additional Locations (1)
Triggered by project rule: PR Review Guidelines for Cursor Bugbot
Reviewed by Cursor Bugbot for commit d79261d. Configure here.


📜 Description
This goes and adds
ExceptionUtils.rethrowIfFatalas well as a comment all over the codebase where we use catchThrowableThis also adds a Javadoc on the user-facing callbacks says what is dropped when they throw, that the error is logged at ERROR (which prints only with
debugenabled), and that fatal errors are rethrown.Some behavior stays as it was:
💡 Motivation and Context
This is part of the
catch (Throwable)audit.💚 How did you test it?
Didn't, this is just rethrowing fatal errors.
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
🤖 Generated with Claude Code