fix(notifications): guard against null PendingResult from goAsync() [SDK-4803]#2667
Merged
Conversation
Contributor
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)0/14 touched executable lines covered (0.0% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
❌ Coverage Check FailedAggregate coverage on touched lines is 0.0% (minimum 80%). |
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
nan-li
approved these changes
Jun 23, 2026
…SDK-4803] BroadcastReceiver.goAsync() is a Java method returning the Kotlin platform type PendingResult!, so the compiler inserts no null check. The platform contract allows goAsync() to return null (observed on background/OEM dispatch, e.g. vivo on Android 14), causing a NullPointerException when pendingResult.finish() is called. Declare pendingResult as an explicit nullable type and guard every finish() dereference with a safe call across all four receivers that share this pattern.
nan-li
approved these changes
Jun 23, 2026
Contributor
|
rebased on main |
This was referenced Jun 23, 2026
abdulraqeeb33
added a commit
that referenced
this pull request
Jun 26, 2026
…SDK-4803] (#2667) Co-authored-by: AR Abdul Azeez <abdul@onesignal.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BroadcastReceiver.goAsync()returns the Kotlin platform typePendingResult!, and the platform contract permits it to returnnull(for example, during background/OEM dispatch such as on vivo devices running Android 14). The receiver code dereferenced the result directly viapendingResult.finish(), which could throw aNullPointerException.This NPE was caught and logged by
suspendifyWithCompletionrather than crashing the host process, but the in-flight work was silently abandoned with no retry.Fix
val pendingResult: BroadcastReceiver.PendingResult? = goAsync().pendingResult.finish()call to the null-safependingResult?.finish()across all four receivers:FCMBroadcastReceiverUpgradeReceiverNotificationDismissReceiverBootUpReceiverNo other behavior changed.
Ticket
Linear: SDK-4803
Test plan
:onesignal:notifications:compileReleaseKotlinpasses:onesignal:notifications:testReleaseUnitTestpassesMade with Cursor