Skip to content

fix: Keep handling LinkageError where the SDK expects it (JAVA-552) - #6666

Draft
runningcode wants to merge 5 commits into
9.x.xfrom
no/java-552-linkage-error-sites
Draft

runningcode wants to merge 5 commits into
9.x.xfrom
no/java-552-linkage-error-sites

Conversation

@runningcode

@runningcode runningcode commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

At these catch (Throwable) sites a LinkageError is an expected failure, not a fatal one: a native library that didn't load, a missing optional dependency, or a mismatched Compose, androidx or framework version. Each site now handles the LinkageError itself, narrowing the catch where it can, and otherwise calls ExceptionUtils.rethrowIfFatal for the rest. The user-facing callbacks also get Javadoc saying what happens when they throw.

Exceptions:

  • In user callbacks and calls into the app's frameworks, a LinkageError shares the catch with other exceptions through an instanceof check before rethrowIfFatal, so the failure handling isn't duplicated.
  • Scopes.close closes each replaceable component in its own LinkageError catch, so one broken component doesn't stop the rest of the shutdown or a re-init. Its outer catch also gets rethrowIfFatal.
  • WindowManagerSpy's reflection is narrowed, but the root view swap gets its own broad catch with rethrowIfFatal, because the swap runs replay's root view listeners.

💡 Motivation and Context

This is part of the catch (Throwable) audit. It's independent of the other JAVA-552 PRs, so it can merge in any order.

💚 How did you test it?

No new tests, only the existing ones.

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

#skip-changelog

🤖 Generated with Claude Code

ExceptionUtils.rethrowIfFatal rethrows LinkageError. At these sites a LinkageError is the expected failure: a native library that failed to load, a missing optional dependency, or a mismatched Compose or androidx version. Each one is narrowed to the types the guarded code throws, or catches LinkageError before a broad catch that calls rethrowIfFatal.

The event processor loops in SentryClient handle a LinkageError like any other processor failure.

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

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

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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: high PR risk score: high risk: medium PR risk score: medium labels Nov 18, 2026
User and hybrid callbacks, the logback encoder, and the Apollo, Servlet and Spring calls in the integrations can throw a LinkageError that isn't fatal there, because an optional module is missing or has an incompatible version. These sites now treat it like any other exception and call ExceptionUtils.rethrowIfFatal for the rest. The options configuration in Sentry.init and SentryAndroid.init continues with the options applied so far.

Scopes.close logs a LinkageError from a replaceable component and goes on with the remaining shutdown steps, while fatal errors propagate. AppState catches failures of the first ON_START dispatch again, so a throwing app state listener can't crash the main looper.

The callback Javadoc moves here with the sites it describes.

Refs #5513

Refs JAVA-552

Co-Authored-By: Claude Opus 5.5 <[email protected]>
runningcode added a commit that referenced this pull request Nov 19, 2026
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]>
@github-actions github-actions Bot removed the risk: medium PR risk score: medium label 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