Repository navigation
Fixes #5439: Fix ConcurrentModificationException - #8686
tanyagoyan-boop wants to merge 4 commits into
Conversation
Using Gemini Code AssistThe 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
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 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. |
📝 PRs merging into main branchOur 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
67c12b5 to
15e52ab
Compare
| - [fixed] `ConcurrentModificationException` crash when a config update listener is removed | ||
| from inside its own callback. (#5439) | ||
|
|
||
| # Unreleased |
| # Unreleased | ||
|
|
||
| - [changed] **Breaking Change**: Updated minSdkVersion to API level 24 or higher. (#8638) | ||
| - [fixed] `ConcurrentModificationException` crash when a config update listener is removed |
There was a problem hiding this comment.
| - [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) |
| # 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) |
There was a problem hiding this comment.
| - [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) |
Problem
The listeners in
ConfigRealtimeHandlerare stored in aLinkedHashSet. If a listener callsremove()inside its ownonError,ConfigRealtimeHttpClient.propagateErrorsthrows aConcurrentModificationExceptionwhile looping over the set. On the main thread (ActivityonResume→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
ConfigRealtimeHandlerTest: listener A removes itself inonError, and the test checks that listener B is still notified. It fails before the fix and passes after.With LinkedHashSet : https://screenshot-v2.corp.google.com/43mnvd33td1bg
With CopyOnWriteArraySet : https://screenshot-v2.corp.google.com/4sl8fqrodc3h8
Beforefix.mov
onErrorand there was no crash.AfterFix.mov