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
AbstractSessionWebSocketMessageBrokerConfigurer triggers eager instantiation of SessionRepository due to non-static declaration of ApplicationListener#3077
Closed
odrotbohm opened this issue
Jul 8, 2024
· 0 comments
AbstractSessionWebSocketMessageBrokerConfigurer declares webSocketRegistryListener() returning an ApplicationListener. As this method is declared non-static, it requires the class to be instantiated, which in turn triggers the injection of autowired dependencies such as the SessionRepository. This might cause a cyclic dependency issue as the repository implementation such as MongoDB might bootstrap infrastructure that in turn needs access to all ApplicationListener instances.
Declaring webSocketRegistryListener() as static method prevents the class from being instantiated to use the bean instance and the subsequent dependency initialization procedure gets shortcut, preventing the cyclic dependency problem.
The text was updated successfully, but these errors were encountered:
AbstractSessionWebSocketMessageBrokerConfigurer
declareswebSocketRegistryListener()
returning anApplicationListener
. As this method is declared non-static, it requires the class to be instantiated, which in turn triggers the injection of autowired dependencies such as theSessionRepository
. This might cause a cyclic dependency issue as the repository implementation such as MongoDB might bootstrap infrastructure that in turn needs access to allApplicationListener
instances.Declaring
webSocketRegistryListener()
as static method prevents the class from being instantiated to use the bean instance and the subsequent dependency initialization procedure gets shortcut, preventing the cyclic dependency problem.The text was updated successfully, but these errors were encountered: