optimizely / optimizely/android-sdk

[BUG] ConcurrentModificationException thrown while calling the decide function

Open
#507 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
56
Forks
36
Avg merge
9h 23m
Merged PRs (30d)
1

Description

Is there an existing issue for this?
  • I have searched the existing issues
SDK Version

5.0.0

Current Behavior
Crash in the optimizely SDK:

Stack trace:

          Caused by java.util.ConcurrentModificationException:
       at java.util.HashMap$HashIterator.nextNode(HashMap.java:1603)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1636)
       at java.util.HashMap$EntryIterator.next(HashMap.java:1634)
       at java.util.HashMap.putMapEntries(HashMap.java:518)
       at java.util.HashMap.<init>(HashMap.java:491)
       at com.optimizely.ab.OptimizelyUserContext.<init>(OptimizelyUserContext.java:72)
       at com.optimizely.ab.OptimizelyUserContext.copy(OptimizelyUserContext.java:106)
       at com.optimizely.ab.OptimizelyUserContext.decide(OptimizelyUserContext.java:143)
       at com.optimizely.ab.OptimizelyUserContext.decide(OptimizelyUserContext.java:153)

Device breakdown:

Image

Data insights:

Image

Expected Behavior

No crash.

Steps To Reproduce

We have been unable to deterministically reproduce this issue.
This is affecting a small percentage of our user base, around 3%

Link

No response

Logs

Nothing relevant outside of the stacktrace already shared

Severity

Affecting users

Workaround/Solution

As this is a side-effect of calling the userContext.decide() There is no workaround that still results in the user receiving a valid decision.

Recent Change

No response

Conflicts

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with OptimizelyUserContext.java, especially the copy and decide methods named in the stack trace. Investigate concurrent calls to userContext.decide() and the HashMap construction that throws ConcurrentModificationException; reproduction is currently nondeterministic. Done means concurrent decide calls no longer crash and still return valid decisions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.