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

Add tests to ensure private constructor is not used for value object binding #42277

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Sep 12, 2024

Sometimes we want to duplicate @ConfigurationProperties bean with different prefix, we should use the primary configuration properties as default of additional configuration properties instead of re-configuring them all, then we could inject that primary bean and copy its values as default via constructor, there are two ways to force constructor used for injection instead of binding, annotating it with @Autowired or marking it as private, and the former one is already covered by tests, this commit add test for latter one.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 12, 2024
@philwebb philwebb changed the title Add tests to ensure @Autowired or private constructor is not used for value object binding Add tests to ensure @Autowired or private constructor is not used for value object binding Sep 12, 2024
@quaff quaff changed the title Add tests to ensure @Autowired or private constructor is not used for value object binding Add tests to ensure private constructor is not used for value object binding Sep 13, 2024
@quaff quaff force-pushed the patch-68 branch 2 times, most recently from 1d73939 to e755d6f Compare September 13, 2024 00:45
…binding

Sometimes we want to duplicate `@ConfigurationProperties` bean with different prefix, we should use the primary configuration properties as default of additional configuration properties instead of re-configuring them all, then we could inject that primary bean and copy its values as default via constructor, there are two ways to force constructor used for injection instead of binding, annotating it with `@Autowired` or marking it as `private`, and the former one is already covered by tests, this commit add test for latter one.
@philwebb
Copy link
Member

Thanks @quaff!

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

Successfully merging this pull request may close these issues.

4 participants