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

Crash NPE on onVenmoFailure listener is null #832

Closed
bruno-facina-penn-int opened this issue Nov 24, 2023 · 3 comments · Fixed by #848
Closed

Crash NPE on onVenmoFailure listener is null #832

bruno-facina-penn-int opened this issue Nov 24, 2023 · 3 comments · Fixed by #848

Comments

@bruno-facina-penn-int
Copy link

Braintree SDK Version

4.33.0

Environment

Production

Android Version & Device

No response

Braintree dependencies

com.braintreepayments.api:paypal:4.33.0,
com.braintreepayments.api:venmo:4.33.0,
com.braintreepayments.api:data-collector:4.33.0,

Describe the bug

NullPointerException - Attempt to invoke interface method 'void com.braintreepayments.api.i2.a caused by VenmoClient.java:305
The listeners are null at that point, oddly it only happens for failure, it is very rare occasions, something is happening with the activity that we are losing the listeners, we also have set the listeners for paypal the same way, but we have no issue there. When looking into your codebase, we have found that paypal checks for the listener to not be null

PaypalClient.java:155

if (error != null && listener != null) {
                    listener.onPayPalFailure(error);
}

while for Venmo there are no checks for the listener not being null,
VenmoClient.java:305

else if (venmoResult.getError() != null) {
            if (venmoResult.getError() instanceof UserCanceledException) {
                braintreeClient.sendAnalyticsEvent("pay-with-venmo.app-switch.canceled");
            }
            listener.onVenmoFailure(venmoResult.getError());
        }

To reproduce

We couldn't reproduce, it has been happening in production.

Expected behavior

The fix for this is very simple, only call the listeners for the VenmoClient if they are not null.

Screenshots

No response

@sarahkoop sarahkoop added the bug label Nov 27, 2023
@sarahkoop
Copy link
Contributor

Hi @bruno-facina-penn-int - Thanks for opening this issue! Agreed this looks like a bug, we can implement a null check before invoking the listeners.

@hollabaq86
Copy link
Contributor

for internal tracking, issue 30167

@sarahkoop
Copy link
Contributor

This fix was released in version 4.40.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants