Skip to content

Safeguard all call class's public methods against NPE - #1758

Draft
rahul-lohra wants to merge 1 commit into
refactor/call-class-decompositionfrom
improvement/rahullohra/wrap-npe-on-decomposed-call
Draft

Safeguard all call class's public methods against NPE#1758
rahul-lohra wants to merge 1 commit into
refactor/call-class-decompositionfrom
improvement/rahullohra/wrap-npe-on-decomposed-call

Conversation

@rahul-lohra

@rahul-lohra rahul-lohra commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Goal

Closes #AND-1350
Safeguard all call class's public methods against NPE

Implementation

Wrap all Call class's public method which returns Result with try-catch

@OptIn(ExperimentalContracts::class)
internal inline fun <T : Any> runResultCatchingCancellable(block: () -> Result<T>): Result<T> {
    contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) }
    return try {
        block()
    } catch (ce: CancellationException) {
        throw ce
    } catch (npe: NullPointerException) {
        Result.Failure(Error.ThrowableError(npe.message ?: "NullPointerException caught", npe))
    }
}

🎨 UI Changes

None

Testing

Smoke test video/audio call

@rahul-lohra rahul-lohra self-assigned this Jul 31, 2026
@rahul-lohra rahul-lohra added the pr:improvement Enhances an existing feature or code label Jul 31, 2026
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.27 MB 12.29 MB 0.02 MB 🟢
stream-video-android-ui-xml 5.68 MB 5.70 MB 0.02 MB 🟢
stream-video-android-ui-compose 6.20 MB 6.20 MB 0.00 MB 🟢

@rahul-lohra rahul-lohra changed the title Safeguard all call class's public methods against NPE [AND-1350] Safeguard all call class's public methods against NPE Jul 31, 2026
@rahul-lohra rahul-lohra changed the title [AND-1350] Safeguard all call class's public methods against NPE Safeguard all call class's public methods against NPE Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Enhances an existing feature or code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant