Skip to content

AbstractSessionWebSocketMessageBrokerConfigurer triggers eager instantiation of SessionRepository due to non-static declaration of ApplicationListener #3077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
odrotbohm opened this issue Jul 8, 2024 · 0 comments
Assignees
Labels
Milestone

Comments

@odrotbohm
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants