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 when calling CheckEligibilityTask.buildParams() #116

Open
adriyanstanchev opened this issue Jan 24, 2022 · 1 comment
Open

Crash when calling CheckEligibilityTask.buildParams() #116

adriyanstanchev opened this issue Jan 24, 2022 · 1 comment

Comments

@adriyanstanchev
Copy link

Hi, we are using the Segment-Wootric integration in our project and we noticed >100 crashes in the last month

The crash is:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$4.done(AsyncTask.java:415)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
       at java.util.concurrent.FutureTask.run(FutureTask.java:271)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)
 Caused by java.util.ConcurrentModificationException
       at java.util.HashMap$HashIterator.nextNode(HashMap.java:1441)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1475)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1473)
       at com.wootric.androidsdk.network.tasks.CheckEligibilityTask.buildParams(CheckEligibilityTask.java:78)
       at com.wootric.androidsdk.network.tasks.WootricRemoteRequestTask.requestParams(WootricRemoteRequestTask.java:128)
       at com.wootric.androidsdk.network.tasks.WootricRemoteRequestTask.doInBackground(WootricRemoteRequestTask.java:73)
       at com.wootric.androidsdk.network.tasks.WootricRemoteRequestTask.doInBackground(WootricRemoteRequestTask.java:44)
       at android.os.AsyncTask$3.call(AsyncTask.java:394)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)      

There is nothing special in our setup, in our MainActivity's onResume() we are just calling:

Analytics.with(this).onIntegrationReady(WootricIntegration.FACTORY.key(), (Analytics.Callback<Wootric>) wootric -> {
            if (wootric != null) {
                wootric.setSurveyColor(R.color.brandLabelClient);
                wootric.setScoreColor(R.color.green_extra_dark);
                wootric.setThankYouButtonBackgroundColor(R.color.colorAccent);
                wootric.survey();
            } else Timber.e(new Exception("Wootric instance is null"));
        });

Library version is the latest com.wootric:analytics-integration-wootric:0.2.0

It looks like the EndUser properties are being updated, while they are being iterated over. The users affected by this issue appear to have not done anything special, just launched the app.
Any suggestions would be appreciated.

Update:

Adding a breakpoint to this line in CheckEligibilityTask and evaluating endUser.properties.clear(), then letting the program run results in the same exception.
So, sometimes the calls to updateEndUserAttributes() happen at the wrong time. Have you seen this behaviour? Should the EndUser.properties be a ConcurrentHashMap if it has concurrency issues 🤔

@diegoserranoa
Copy link
Contributor

Hi @adriyanstanchev thanks for reporting this. I haven't seen this happen before but it seems like it does have something to do with concurrency. I'll take a look at this as soon as I can.

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

No branches or pull requests

2 participants