Skip to content

Fixes #5439: Fix ConcurrentModificationException - #8686

Open
tanyagoyan-boop wants to merge 4 commits into
mainfrom
fix-5439-listener-cme
Open

tanyagoyan-boop wants to merge 4 commits into
mainfrom
fix-5439-listener-cme

Conversation

@tanyagoyan-boop

Copy link
Copy Markdown

Problem

The listeners in ConfigRealtimeHandler are stored in a LinkedHashSet. If a listener calls remove() inside its own onError, ConfigRealtimeHttpClient.propagateErrors throws a ConcurrentModificationException while looping over the set. On the main thread (Activity onResume → setBackgroundState(false) → makeRealtimeHttpConnection), the app crashes with "Unable to resume activity".

Fix

Store the listeners in a CopyOnWriteArraySet. Loops then run over a snapshot of the set, so a listener can remove itself mid-loop without breaking it.

Testing

Beforefix.mov
  • After the fix, both listeners received onError and there was no crash.
AfterFix.mov

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

… a callback

Use CopyOnWriteArraySet for realtime listeners so a listener can add or remove itself in onUpdate/onError without breaking notification of others.

Fixes #5439
@tanyagoyan-boop
tanyagoyan-boop requested review from google-oss-bot and rlazo and removed request for dsjadaun-google and tusharkhandelwal8 October 9, 2026 12:10
Comment thread firebase-config/CHANGELOG.md Outdated
- [fixed] `ConcurrentModificationException` crash when a config update listener is removed
from inside its own callback. (#5439)

# Unreleased

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicated section

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed.

Comment thread firebase-config/CHANGELOG.md Outdated
# Unreleased

- [changed] **Breaking Change**: Updated minSdkVersion to API level 24 or higher. (#8638)
- [fixed] `ConcurrentModificationException` crash when a config update listener is removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [fixed] `ConcurrentModificationException` crash when a config update listener is removed
- [fixed] Fixed a `ConcurrentModificationException` crash when a config update listener is removed
from inside its own callback. (#5439)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

Comment thread firebase-config/CHANGELOG.md Outdated
# Unreleased

- [changed] **Breaking Change**: Updated minSdkVersion to API level 24 or higher. (#8638)
- [fixed] Fixed a `ConcurrentModificationException` crash when a config update listener is removed from inside its own callback. (#5439)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [fixed] Fixed a `ConcurrentModificationException` crash when a config update listener is removed from inside its own callback. (#5439)
- [fixed] Fixed a `ConcurrentModificationException` crash when a config update listener is removed from inside its own callback. (#8686)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@tanyagoyan-boop
tanyagoyan-boop enabled auto-merge (squash) October 13, 2026 18:19

This branch has not been deployed

No deployments
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.

3 participants