Repository navigation
fix: Add a bunch of ExceptionUtils.rethrowIfFatal so we don't swallow fatal errors (JAVA-552) - #6665
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.
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 <noreply@anthropic.com>
PR risk: not classifiedFor commit The last run ended with status |
adinauer
left a comment
There was a problem hiding this comment.
In theory, we could perform minimal, best-effort cleanup at some locations:
- ReplayCache: release/reset the active encoder and recycle the bitmap.
- ScreenshotUtils: ensure the bitmap is recycled.
- SentryJobListener: close the lifecycle token and restore the previous scope.
- ReplayExecutorService: ensure the fatal error is observable rather than retained in an ignored Future.
In case a framework / executor catches those exceptions and decides to reuse the process / worker thread, we might end up with a poisoned state.
But still, the cleanup shouldn't mask the original exception.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

📜 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.💡 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