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
There is a race condition in Popover static functions. If multiple threads call Popover.setDefaultHideDelay() at the same time, that can result in multiple calls to applyConfiguration() and multiple registrations of UI init listener.
The easiest way is to mark all static set*() functions as synchronized. Alternatively, you can use AtomicInteger for all static fields (don't forget to make them final!) and use uiInitListenerRegistered.compareAndSet() in applyConfiguration().
Expected outcome
The UI Init Listener is registered at most once, regardless of how many threads call Popover static functions at the same time.
Alternatively, tell the programmer to call those static functions in a service init listener (which is called exactly once), or from a Spring singleton - but this is more complex and more demanding on the user.
Minimal reproducible example
As is the nature of threading bugs, they are not easy to reproduce. I can create an example program though if you need one 👍
Steps to reproduce
Create an executor with 10 threads; use CountdownLatch to start them at the same time, then start setting the default Focus Delay in a loop. Alternatively, set default focus delay in a session init listener then start DDOS on the web server, but this is harder.
Observe that multiple UI init listeners are registered, because of race condition.
Environment
Vaadin version(s): 24.5.5+
Browsers
No response
The text was updated successfully, but these errors were encountered:
Description
There is a race condition in Popover static functions. If multiple threads call
Popover.setDefaultHideDelay()
at the same time, that can result in multiple calls toapplyConfiguration()
and multiple registrations of UI init listener.The easiest way is to mark all static
set*()
functions assynchronized
. Alternatively, you can useAtomicInteger
for all static fields (don't forget to make them final!) and useuiInitListenerRegistered.compareAndSet()
inapplyConfiguration()
.Expected outcome
The UI Init Listener is registered at most once, regardless of how many threads call Popover static functions at the same time.
Alternatively, tell the programmer to call those static functions in a service init listener (which is called exactly once), or from a Spring singleton - but this is more complex and more demanding on the user.
Minimal reproducible example
As is the nature of threading bugs, they are not easy to reproduce. I can create an example program though if you need one 👍
Steps to reproduce
Environment
Vaadin version(s): 24.5.5+
Browsers
No response
The text was updated successfully, but these errors were encountered: