-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
MOB-22620: Fix concurrent modification exception during session termination #147
Conversation
Problem: `notifyTerminationAndRemoveStatusListeners()` iterates over all the connection status listeners to notify disconnection and un-registers them. Since the de-registration process involves removing the listeners from the set, iterating over the same list for removal leads to ConcurrentModificationException and not all listeners are notified of the error. This results in the connecting icon spinning forever. Solution: Iterate for de-registration over a copy of the listeners to prevent the exception and propogate the error.
|
||
// Unregister all the listeners. Operate on a copy of the listeners as | ||
// unregisterStatusListener modifies the listeners set. | ||
final Set<AssuranceSessionStatusListener> listenersCopy = |
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.
How about sessionStatusListeners.clear()
?
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.
Yes! Clearing here is better. Will patch.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-v3.x #147 +/- ##
==============================================
- Coverage 71.26% 71.20% -0.06%
+ Complexity 413 411 -2
==============================================
Files 66 66
Lines 3274 3271 -3
Branches 403 402 -1
==============================================
- Hits 2333 2329 -4
- Misses 727 730 +3
+ Partials 214 212 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Description
Problem
notifyTerminationAndRemoveStatusListeners()
iterates over all the connection status listeners to notify disconnection and un-registers them. Since the de-registration process involves removing the listeners from the set, iterating over the same list for removal leads to ConcurrentModificationException and not all listeners are notified of the error. This results in the connecting icon spinning forever.This situation only occurs for terminal errors/ non retryable errors so it does not affect the normal workflow.
Solution
Iterate for de-registration over a copy of the listeners to prevent the exception and propagate the error.
Related Issue
MOB-22620
Motivation and Context
notifyTerminationAndRemoveStatusListeners()
iterates over all the connection status listeners to notify disconnection and un-registers them. Since the de-registration process involves removing the listeners from the set, iterating over the same list for removal leads to ConcurrentModificationException and not all listeners are notified of the error. This results in the connecting icon spinning forever.As a solution, iterate for de-registration over a copy of the listeners to prevent the exception and propagate the error.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: