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

CF-241 Amazon is swallowing all exceptions that happen in the listeners #499

Merged
merged 2 commits into from Mar 1, 2022

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Feb 26, 2022

CF-241

I noticed offerings were not loading. Products were failing to load. There was no exceptions or anything. But after a lot of debugging I found this little gem in Amazon's code:

                     try {
                        if (var1 instanceof ProductDataResponse) {
                            var3.onProductDataResponse((ProductDataResponse)var1);
                        } else if (var1 instanceof UserDataResponse) {
                            var3.onUserDataResponse((UserDataResponse)var1);
                        } else if (var1 instanceof PurchaseUpdatesResponse) {
                            var3.onPurchaseUpdatesResponse((PurchaseUpdatesResponse)var1);
                        } else if (var1 instanceof PurchaseResponse) {
                            var3.onPurchaseResponse((PurchaseResponse)var1);
                        } else {
                            e.b(c.a, "Unknown response type:" + var1.getClass().getName());
                        }
                    } catch (Exception var2) {
                        e.b(c.a, "Error in sendResponse: " + var2);
                    }

They are basically catching all Exceptions that happen in the listener we implemented. I also noticed they display a short log while in App Tester but not when the app is downloaded from Live App Testing.

@vegaro vegaro marked this pull request as ready for review February 26, 2022 02:26
@@ -42,21 +43,27 @@ class PurchaseHandler(
}

override fun onPurchaseResponse(response: PurchaseResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a common base type for all of the Responses so that we can avoid code duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no... they are all different and no base class 😭

val expectedException = RuntimeException("")
var receivedException: Throwable? = null
var receivedLoggedException: Throwable? = null
Purchases.logHandler = object : LogHandler {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yayyy we can finally test logs!

Copy link
Contributor

@beylmk beylmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧯 looks good, just the one question on code duplication

@vegaro vegaro merged commit ded438b into main Mar 1, 2022
@vegaro vegaro deleted the fix-exceptions branch March 1, 2022 18:13
@vegaro vegaro mentioned this pull request Mar 22, 2022
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

2 participants