Follow best practice for listener notification
When notifying listeners, it's best practice not to hold any locks. Holding locks during synchronous notifications can cause deadlocks. One case has been caught where: A flag affecting the ConfigurationInternal managed by timezonedector.ServiceConfigAccessorImpl was updated: this caused the main thread to hold the ServiceConfigAccessorImpl "this" monitor while notifying the TimeZoneDetectorStrategyImpl (requiring the TimeZoneDetectorStrategyImpl "this" lock). Simultaneously, another (binder) thread was calling into TimeZoneDetectorStrategyImpl to update user configuration, thus holding the TimeZoneDetectorStrategyImpl "this" lock but attempting to read the ConfigurationInternal from the ServiceConfigAccessorImpl, and requiring the ServiceConfigAccessorImpl "this" monitor. Classic deadlock. This commit modifies (or comments) listener notification code to prevent deadlocks. Bug: 259562789 Test: Treehugger Change-Id: I93b1d9d82ca96062f760c77043e6837398f03cc5
Loading
Please register or sign in to comment