android-sdk icon indicating copy to clipboard operation
android-sdk copied to clipboard

[BUG] ConcurrentModificationException thrown while calling the decide function

Open marctatham opened this issue 9 months ago • 1 comments

Is there an existing issue for this?

  • [x] 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

marctatham avatar Mar 25 '25 11:03 marctatham

@marctatham we have the same issue. Would be good to mark these decice, decideAll, etc. methods with @NotThreadSafe annotation if it's expected or designed behavior.

nalivajr avatar Dec 02 '25 11:12 nalivajr