Skip to content
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

Favor ObjectProvider over custom getBeanOrNull method #15805

Closed
jzheaux opened this issue Sep 13, 2024 · 2 comments · Fixed by #15816
Closed

Favor ObjectProvider over custom getBeanOrNull method #15805

jzheaux opened this issue Sep 13, 2024 · 2 comments · Fixed by #15816
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Sep 13, 2024

Internal to many of Spring Security's configuration classes is a technique for ensuring that it only uses beans with a unique instance in the application context.

Spring Framework's ObjectProvider exposes an API for this kind of thing and it would be interesting to see how many places we could replace this custom code using ApplicationContext#getBeanProvider.

@jzheaux jzheaux added in: core An issue in spring-security-core type: enhancement A general enhancement labels Sep 13, 2024
@ngocnhan-tran1996
Copy link
Contributor

@jzheaux

Can you assign me this task?

@jzheaux
Copy link
Contributor Author

jzheaux commented Sep 16, 2024

Yes, @ngocnhan-tran1996, thank you for volunteering.

As part of making this change, I'd recommend ensuring that all test cases are present for cases where there is no bean, one bean, and multiple beans. This will make it clear that replacing getBeanOrNull with ObjectProvider hasn't changed behavior.

@jzheaux jzheaux changed the title Consider Favoring ObjectProvider over custom getBeanOrNull method Favor ObjectProvider over custom getBeanOrNull method Sep 17, 2024
jzheaux pushed a commit that referenced this issue Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants