Skip to content

fix: Annotate nullable array returns on the array, not the element - #6558

Open
runningcode wants to merge 2 commits into
mainfrom
no/jetbrains-nullable-array-returns
Open

runningcode wants to merge 2 commits into
mainfrom
no/jetbrains-nullable-array-returns

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Moves the JetBrains @Nullable from the element type to the array on six public methods that return a nullable array:

  • Attachment.getBytes()
  • Device.getArchs()
  • Spring.getActiveProfiles()
  • ContextUtils.getSplitNames()
  • JsonSerializationUtils.bytesFrom(...)
  • QueueFile.peek()

💡 Motivation and Context

JetBrains @Nullable is a TYPE_USE annotation, so @Nullable byte[] marks the element type, not the array. Kotlin saw these returns as ByteArray and Array<String>, although they can return null. With byte @Nullable [] Kotlin sees ByteArray? and Array<String>?.

Follow-up to the review on #6497, which fixed the same thing on ViewHierarchyEventProcessor.snapshotViewHierarchyAsData. The ScreenshotUtils returns use androidx.annotation.Nullable, a declaration annotation that Kotlin already reads as a nullable return, so they stay as they are.

💚 How did you test it?

A Kotlin assignment of each kind of return to a non-null type now fails to compile. The Kotlin tests of the modules that call these methods still compile, and their unit tests 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

Kotlin code that uses these returns as non-null, for example attachment.bytes.size, no longer compiles until it handles null.

🤖 Generated with Claude Code

runningcode and others added 2 commits November 11, 2026 12:49
JetBrains @nullable is a TYPE_USE annotation, so @nullable byte[] marks
the element type and Kotlin saw ByteArray instead of ByteArray?. Moving
it to byte @nullable [] makes Kotlin see the nullable return.

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

sentry Bot commented Nov 11, 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 11, 2026 14:28
@runningcode
runningcode requested review from a team and adinauer as code owners November 11, 2026 14:28
@runningcode
runningcode requested review from 0xadam-brown and markushi and removed request for a team November 11, 2026 14:28
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Nov 11, 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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant