Skip to content

fix(android): Resolve NullAway findings in sentry-android-core - #6497

Merged
runningcode merged 5 commits into
mainfrom
no/android-core-nullaway
Nov 11, 2026
Merged

runningcode merged 5 commits into
mainfrom
no/android-core-nullaway

Conversation

@runningcode

@runningcode runningcode commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

This adds @Nullable and fixes the NullAway findings in sentry-android-core.

💡 Motivation and Context

NullAway is set to ERROR for sentry-android-core but never ran, because Error Prone didn't run there at all (#6493). This is one of four independent PRs that fix what it reports. It targets main because it breaks no 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: no NullAway findings 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

ViewHierarchyEventProcessor.snapshotViewHierarchyAsData is now @Nullable. It already returned null when the hierarchy couldn't be captured. Kotlin callers in hybrid SDKs now see ByteArray? and have to handle null.

Issues

🤖 Generated with Claude Code

#skip-changelog

@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

@runningcode
runningcode marked this pull request as ready for review November 10, 2026 08:09
@runningcode
runningcode requested review from a team and adinauer as code owners November 10, 2026 08:09
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 10, 2026 08:09
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Nov 10, 2026
@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

JAVA-831

runningcode and others added 2 commits November 10, 2026 09:29
NullAway never ran on sentry-android-core. Enabling it reports 32 errors. Most are fields and
return types that are nullable but not annotated, and fields NullAway cannot see as checked
because a check happens in a different scope (a lambda, another method) than the dereference.

- Annotate the nullable fields and return types, including ViewHierarchyNode.setType and
  UiElement.equals in the sentry module.
- Read options once in lambdas, and pass scopes and options to
  createStandaloneAppStartTransaction, whose callers already check them.
- Compute the device family once instead of through a LazyEvaluator, whose evaluator must not
  return null.
- Create the system events HandlerThread in the branch that uses it, inside the existing try.

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

The filter was a nullable field, built on the first registration and cleared in close(). It
only depends on the final actions array, so build it in the registration task instead. That
leaves nothing nullable to track.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/android-core-nullaway branch from 984b01c to 4f3e92b Compare November 10, 2026 08:31
@runningcode
runningcode changed the base branch from 9.x.x to main November 10, 2026 08:32
finishAppStartSpan passed the nullable options field to getAppStartTimeSpanWithFallback, which
NullAway reports on main. The end time is only used when performance is enabled, which register()
sets together with options, so return early when either is unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/android-core-nullaway branch from 4f3e92b to 11f129a Compare November 10, 2026 08:41
# Conflicts:
#	sentry-android-core/src/main/java/io/sentry/android/core/internal/util/AndroidConnectionStatusProvider.java

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

One question on my end worth considering before merging. Otherwise lgtm.

@nullable byte[] annotates the element type for TYPE_USE annotations, so
Kotlin saw ByteArray instead of ByteArray?.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode merged commit 072775b into main Nov 11, 2026
46 checks passed
@runningcode
runningcode deleted the no/android-core-nullaway branch November 11, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants