Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE on Kotlin when callbacks returned a nullable value #344

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

lbalmaceda
Copy link
Contributor

Changes

On a previous PR, we introduced annotations to prevent the Kotlin compiler from guessing the nullability of the SDK's params and returned values by rather being explicit. This fix to the lint warnings was meant to improve the compatibility when this SDK was used in a Kotlin environment.

In the case of the callbacks that returned a Void type, those were annotated as "Non-null" and still returned null, given that the return value is not supposed to be used. However, Kotlin was checking its nullability on runtime crashing the app with an NPE when the value of a declared non-null variable was null.

This was not caught in unit tests because we are not using Kotlin to compile this SDK nor run its tests. This only affects Kotlin codebases.

The fix was to roll back those changes in particular to the value that could be returned in a BaseCallback implementation, changing it back again to Nullable.

References

Fixes #341

Testing

I've manually tested this on a kotlin app. Calling methods that make use of the VoidRequest (like the logout manager), an AuthenticationCallback implementation that returns null (like passwordless/start), and a regular API call that returns a different type.

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@lbalmaceda lbalmaceda added the small Small review label Sep 16, 2020
@lbalmaceda lbalmaceda requested a review from a team September 16, 2020 21:05
@lbalmaceda lbalmaceda changed the title Rollback non-null annotations in callbacks to fix NPE for Kotlin Fix NPE on Kotlin when callbacks returned a nullable value Sep 16, 2020
@lbalmaceda lbalmaceda merged commit 053282a into master Sep 16, 2020
@lbalmaceda lbalmaceda deleted the fix-kotlin-annotations branch September 16, 2020 21:22
@lbalmaceda lbalmaceda modified the milestones: v1-Next, 1.26.1 Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Fixed small Small review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Kotlin] 1.26.0 NPE on VoidRequest success flow
2 participants