You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent deadlock when accessing FeatureFlags (#17645)
Synchronizing over FeatureFlags class in FeatureFlags.get could lead to
a deadlock when the call comes from a supplier provided to
VaadinContext.getAttribute() and concurrently from another request.
For example, in the linked issue:
- thread A invokes IndexHtmlRequestHandler.getCachedIndexHtmlDocument(),
that locks the ServletContext through VaadinContext.getAttribute(...)
providing a supplier that calls FeatureFlags.get()
- thread B concurrently executes IndexHtmlRequestHandler.getIndexHtmlDocument()
that also calls FeatureFlags.get() that locks on FeaturFlags class
When B invokes FeatureFlags.get() -> VaadinContext.getAttribute() it has
to wait because ServletContext is already locked A, but A is calling
FeatureFlags.get() and it is waiting to lock on FeatureFlags class.
This change removes the synchronization on FeatureFlags class and relies
on VaadinContext.getAttribute(Class, Supplier) internal synchronization
to prevent FeatureFlag two be instanciated more than once.
It also adds test to ensure there are no regressions for #13962.
Fixes#17637
0 commit comments