salesforce / salesforce/AgentforceMobileSDK-Android

ConcurrentModificationException in MIAWCoreConversationManager.insertBySequence during streaming component creation

Open
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
7
Forks
4
Avg merge
4h 9m
Merged PRs (30d)
1

Description

Description

A ConcurrentModificationException is thrown inside the SDK when a streaming component is being inserted into the conversation entry list. The list backing the conversation components is being structurally modified (add/remove) while it is being iterated, in insertBySequence.

This happens during handleCoreClientEventconvertConversationEntryToAgentforceComponentgetOrCreateStreamingComponentinsertBySequence, which suggests it triggers when streaming entries arrive/update while a prior conversation entry conversion is still in flight.

Stack Trace

Fatal Exception: java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1112) at java.util.ArrayList$Itr.next(ArrayList.java:1065) at com.salesforce.android.agentforcesdkimpl.conversationservice.MIAWCoreConversationManager.insertBySequence(MIAWCoreConversationManager.kt:2265) at com.salesforce.android.agentforcesdkimpl.conversationservice.MIAWCoreConversationManager.getOrCreateStreamingComponent(MIAWCoreConversationManager.kt:1687) at com.salesforce.android.agentforcesdkimpl.conversationservice.MIAWCoreConversationManager.convertConversationEntryToAgentforceComponent(MIAWCoreConversationManager.kt:1014) at com.salesforce.android.agentforcesdkimpl.conversationservice.MIAWCoreConversationManager.access$convertConversationEntryToAgentforceComponent(MIAWCoreConversationManager.kt) at com.salesforce.android.agentforcesdkimpl.conversationservice.MIAWCoreConversationManager$handleCoreClientEvent$3.invokeSuspend(MIAWCoreConversationManager.kt:1212) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt)

Suspected Root Cause

insertBySequence (MIAWCoreConversationManager.kt:2265) appears to iterate over the conversation component ArrayList while adding/removing an element in the same loop, causing the iterator's modCount mismatch. The coroutine dispatcher context may make it look concurrent, but this is a single-thread structural-modification bug in the iteration loop.

Suggested Fix

Iterate over a snapshot (list.toList()), use an explicit index / ListIterator for in-place mutation, or collect insertions and apply them after the loop.

Environment

Crash

  • Date: Jul 10, 2026, 9:00:26 AM

Device

  • Brand: Samsung
  • Model: SM-S948U (Galaxy S25 Ultra)
  • Orientation: Portrait
  • RAM free: 2 GiB
  • Disk free: 152.55 GiB

Operating System

  • Version: Android 16

  • Orientation: Portrait

  • Rooted: No

  • Frequency: <intermittent / consistent — fill in>

Steps to Reproduce
  1. <fill in — likely rapid/overlapping streaming responses in an Agentforce conversation>

3.

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 in MIAWCoreConversationManager.kt at insertBySequence around line 2265, then trace getOrCreateStreamingComponent and handleCoreClientEvent in the stack trace. Reproduce overlapping streaming-entry updates if possible and verify that conversation component insertion no longer throws ConcurrentModificationException during streaming creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.