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

Update demo app Clients from lateinit vars to nullable vars #256

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

tdchow
Copy link
Contributor

@tdchow tdchow commented Apr 29, 2024

Summary of changes

  • Convert Clients from a lateinit var to a nullable var in the demo app for card and PayPal web flows

There were crashes in the demo app where lateinit Clients were not getting set either due to a network error or if the activity was cleared without setting the client. These crashes were introduced when the removeObservers() function was added to the clients.

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@tdchow tdchow requested a review from a team as a code owner April 29, 2024 15:25
@sarahkoop
Copy link
Contributor

These errors are specific to our demo app integration right? I don't quite understand what in the removeObservers method would cause clients to be set to null - but wondering if this would impact merchant integrations too

@tdchow
Copy link
Contributor Author

tdchow commented Apr 29, 2024

These errors are specific to our demo app integration right? I don't quite understand what in the removeObservers method would cause clients to be set to null - but wondering if this would impact merchant integrations too

Yep, these are crashes due to how the demo app's ViewModels declare the client instances as lateinit. If the ViewModel never sets the Client and the Activity is cleared, kotlin.UninitializedPropertyAccessException: lateinit property cardClient has not been initialized is thrown, when removeObservers() is called on an uninitialized client object.

If merchants followed this pattern in their integration, they'd also need to convert from a lateinit var to a nullable var.

@sarahkoop
Copy link
Contributor

These errors are specific to our demo app integration right? I don't quite understand what in the removeObservers method would cause clients to be set to null - but wondering if this would impact merchant integrations too

Yep, these are crashes due to how the demo app's ViewModels declare the client instances as lateinit. If the ViewModel never sets the Client and the Activity is cleared, kotlin.UninitializedPropertyAccessException: lateinit property cardClient has not been initialized is thrown, when removeObservers() is called on an uninitialized client object.

If merchants followed this pattern in their integration, they'd also need to convert from a lateinit var to a nullable var.

Should we add more docs to the removeObservers method to call this out? This only applies if merchants start using that method correct? (trying to confirm it's not a breaking change)

@tdchow
Copy link
Contributor Author

tdchow commented Apr 29, 2024

These errors are specific to our demo app integration right? I don't quite understand what in the removeObservers method would cause clients to be set to null - but wondering if this would impact merchant integrations too

Yep, these are crashes due to how the demo app's ViewModels declare the client instances as lateinit. If the ViewModel never sets the Client and the Activity is cleared, kotlin.UninitializedPropertyAccessException: lateinit property cardClient has not been initialized is thrown, when removeObservers() is called on an uninitialized client object.
If merchants followed this pattern in their integration, they'd also need to convert from a lateinit var to a nullable var.

Should we add more docs to the removeObservers method to call this out? This only applies if merchants start using that method correct? (trying to confirm it's not a breaking change)

Yeah, I think we can call this out in the devdocs. Have we already made initial updates to the devdocs to add this function?

I wouldn't call this a breaking change since the merchant owns the instantiation and management of the client instances.

@tdchow tdchow merged commit 8533f5d into main Apr 29, 2024
7 checks passed
@tdchow tdchow deleted the fix-demo-app-crash branch April 29, 2024 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants