Skip to content

fix: Rethrow fatal errors at the SDK's boundary catches (JAVA-552) - #6665

Open
runningcode wants to merge 7 commits into
9.x.xfrom
no/java-552-rethrow-if-fatal
Open

runningcode wants to merge 7 commits into
9.x.xfrom
no/java-552-rethrow-if-fatal

Conversation

@runningcode

@runningcode runningcode commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

This goes and adds ExceptionUtils.rethrowIfFatal as well as a comment all over the codebase where we use catch Throwable

This 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 debug enabled), 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

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

  • The sentry-docs note on how users find out that their callbacks fail comes with the 9.0.0 migration guide.

🤖 Generated with Claude Code

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 <[email protected]>
@linear-code

linear-code Bot commented Nov 18, 2026

Copy link
Copy Markdown

JAVA-552

@github-actions

Copy link
Copy Markdown
Contributor

🚨 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:

  • sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java
  • sentry/src/main/java/io/sentry/transport/HttpConnection.java

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sentry

sentry Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

runningcode and others added 2 commits November 18, 2026 18:33
Refs #5513

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
runningcode added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
runningcode added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
runningcode added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 18, 2026
runningcode added a commit that referenced this pull request Nov 18, 2026
SentryEnvelopeItem.fromClientReport only throws IOException. The name is fully qualified so this PR doesn't touch the import block, where #6665 adds ExceptionUtils right next to it.

Refs #5513

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 18, 2026
@runningcode
runningcode marked this pull request as ready for review November 19, 2026 07:40
@runningcode
runningcode requested a review from a team as a code owner November 19, 2026 07:40
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 19, 2026 07:40
@github-actions github-actions Bot removed the risk: high PR risk score: high label Nov 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Sites whose try wraps user or hybrid callbacks, or code from compileOnly modules, can see a LinkageError that is not fatal there, so they move to #6666, which handles it at the call site. The screenshot and replay capture sites move to the bitmap OOM PR, and the callback Javadoc moves with the sites it describes.

Refs #5513

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Nov 19, 2026

This branch has not been deployed

No deployments
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.

1 participant