Skip to content

ref(android): Fix Error Prone warnings in sentry-android-core - #6499

Merged
runningcode merged 7 commits into
mainfrom
no/android-core-errorprone-warnings
Nov 11, 2026
Merged

runningcode merged 7 commits into
mainfrom
no/android-core-errorprone-warnings

Conversation

@runningcode

@runningcode runningcode commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Fixes the other 57 warnings Error Prone reports in sentry-android-core:

  • Suppresses FutureReturnValueIgnored (18), JavaUtilDate (4) and ReferenceEquality (12) at method level, as the sentry module does. Every reference comparison is meant to be by identity: activities, dialogs, windows and transactions.
  • Removes the two UnnecessaryLambda suppressions. build(android): Run Error Prone and NullAway on the Android modules #6493 compiles the Android modules with -XDandroidCompatible=true, which makes Error Prone skip UnnecessaryLambda and DefaultCharset there, as Android's default charset is always UTF-8.
  • Removes unused fields and parameters, adds missing @Override, makes long-to-double conversions explicit, and narrows members that are effectively private or protected in a final class.
  • Explains in a comment why the two empty catch blocks ignore their exception.

💡 Motivation and Context

Error Prone never ran on sentry-android-core (#6493). Under -Werror these warnings fail the build once it does. This is one of four independent PRs that fix what it reports. It targets main because it breaks no public API (the .api dumps are unchanged); it reaches 9.x.x with the next merge from main.

💚 How did you test it?

Compiled with Error Prone enabled: none of these warnings remain and none are added. The unit tests of the touched classes pass.

📝 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

Issues

🤖 Generated with Claude Code

#skip-changelog

@github-actions

github-actions Bot commented Nov 6, 2026

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

sentry Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

JAVA-831

runningcode and others added 2 commits November 10, 2026 10:57
Error Prone never ran on sentry-android-core. Enabling it reports 59 warnings outside Javadoc,
which fail the build under -Werror.

- Suppress FutureReturnValueIgnored, JavaUtilDate, and ReferenceEquality where identity is
  intended, as the sentry module does.
- Keep the AnrProfilingIntegration updater a field, since removeCallbacks needs the instance that
  was posted, and suppress UnnecessaryLambda there.
- Read the ANR thread dump and the app start profiling config as UTF-8, Android's default charset.
- Remove unused fields and parameters, add missing @OverRide, make long-to-double conversions
  explicit, and narrow members that are effectively private or protected in a final class.
- Explain the two catch blocks that ignore their exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ANRWatchDog.monotonicTicker is never read (#6041), since the ticker lambda captures the
  constructor parameter. Remove the field and keep the parameter.
- ActivityFramesTracker.lock is protected in a final class; make it package-private.
- LifecycleWatcher reads the session start Date to seed the session window; suppress JavaUtilDate
  there, as the other Date uses are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode changed the base branch from 9.x.x to main November 10, 2026 09:58
@runningcode
runningcode force-pushed the no/android-core-errorprone-warnings branch from 27e4672 to c794404 Compare November 10, 2026 09:58
runningcode and others added 3 commits November 10, 2026 14:29
Android's default charset is always UTF-8, so DefaultCharset is
disabled for the Android modules in #6493 instead of being fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#6493 disables UnnecessaryLambda for the Android modules, so the
suppressions on the ANRWatchDog and AnrProfilingIntegration fields
are redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode runningcode added the sanity-check PR needs a lightweight review for obvious issues label Nov 10, 2026
@runningcode
runningcode marked this pull request as ready for review November 10, 2026 13:39
@runningcode
runningcode requested review from a team and adinauer as code owners November 10, 2026 13:39
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 10, 2026 13:39
runningcode and others added 2 commits November 10, 2026 15:22
…prone-warnings

# Conflicts:
#	sentry-android-core/src/main/java/io/sentry/android/core/internal/util/AndroidConnectionStatusProvider.java
Error Prone's NotJavadoc flags Javadoc on methods of local classes, which
#6537 added in AndroidConnectionStatusProvider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

🥇

@runningcode
runningcode merged commit 40c9b1e into main Nov 11, 2026
46 of 49 checks passed
@runningcode
runningcode deleted the no/android-core-errorprone-warnings branch November 11, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sanity-check PR needs a lightweight review for obvious issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants