fix: prevent NPE crash in FastMpay bank mismatch and amount confirmation sheets#2024
fix: prevent NPE crash in FastMpay bank mismatch and amount confirmation sheets#2024ayuxsh009 wants to merge 1 commit into
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi, @ayuxsh009 We appreciate your Pull Request. To facilitate seamless integration and collaboration, please ensure you have joined our Slack workspace and the relevant designated channel. We recommend thoroughly reviewing the bookmark pages, project README, and wiki to gain a comprehensive understanding of the project architecture and development guidelines. Active participation in the daily stand-up meetings is encouraged for discussions, ticket assignments, and to foster connections with the development team. Prior to requesting an assignment in the channel, please create a Jira ticket or ask for an assignment of existing tickets. All pull request descriptions must comprehensively detail the before and after changes, substantiated by relevant video or image evidence. |
|
Hi @niyajali, thank you for the guidance. I’ll create a Jira ticket for the issue and follow the proper contribution process for future work. Looking forward to contributing more. |
Description
The
FastMpayScreencontained two unsafe non-null assertions (!!) on nullable mutable Compose state variables inside conditional null checks.Because
bankMismatchDataandpendingAmountConfirmationare mutablevarCompose states, recomposition could occur between the null check and the!!dereference, causing the value to becomenullmid-execution and resulting in aNullPointerException.Affected Scenarios
Fix
Fixes #2023
Replaced unsafe
!!assertions by snapshotting nullable mutable state into local immutablevalvariables before the conditional checks.This allows Kotlin smart casts to safely guarantee non-null values inside the block and removes the need for
!!.Changes
FastMpayScreen.kt!!assertions with safe localvalsnapshotsTesting
All existing unit tests pass:
FastMpayProcessorTest× 15FastMpayViewModelTest× 9Platforms Affected
(all Compose targets)
Apply the
AndroidStyle.xmlstyle template to your code in Android Studio.Run the unit tests with
./gradlew checkto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.