-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is a small gap in the SynchronizedWeakHashSet implementation. T… #24015
There is a small gap in the SynchronizedWeakHashSet implementation. T… #24015
Conversation
…he containsKey method of the WeakHashMap is modifying hence calling it during the iteration might cause ConcurrentModificationException. Added a command DO_IF_CONTAINS to safely handle this case.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fkgozali has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @dryganets in 62d3409. When will my fix make it into a release? | Upcoming Releases |
Thanks for the fix! We'll update you if related crash still happens in the future. cc @cpojer |
@dryganets - looks like the same crash is still happening:
It's on the same line as before in SynchronizedWeakHashSet.java:
Thoughts on further corner cases to handle? cc @cpojer |
@fkgozali, The iterators are protected with the lock. |
Summary
There is a small gap in the SynchronizedWeakHashSet implementation - the containsKey method of the WeakHashMap is modifying hence calling it during the iteration might cause ConcurrentModificationException. Added a command DO_IF_CONTAINS to safely handle this case.
Changelog
[Android] [Bugfix] - Should fix a ConcurrentModificationException in onResume.
Test Plan
It is hard to reproduce this problem as this is a race condition.
You rather need to have a good set of integration tests or check it in production.