-
Notifications
You must be signed in to change notification settings - Fork 625
Enable proper override of binder beans with user-defined configurations in a multi-binder scenario #3123
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
Conversation
…user-defined beans over binder's conditional beans in a multi-binder scenario This change modifies the loading order in DefaultBinderFactory.initializeBinderContextSimple to ensure that user configuration classes specified via spring.main.sources are loaded before binder configuration classes. This allows @ConditionalOnMissingBean annotations in the binder configurations to properly detect user-provided beans. Previously, when using KafkaBinderConfiguration with @ConditionalOnMissingBean(KafkaBinderMetrics.class), even if the user had configured a custom KafkaBinderMetrics bean via spring.main.sources, the condition would not work correctly because binder classes were loaded first. Fixes spring-cloudgh-3114 Signed-off-by: ferblaca <[email protected]>
@ferblaca I thought you would add a |
Hi @sobychacko!! After reviewing the issue, I noticed that it seemed to be a more general BUG in And to avoid mixing things up, I preferred to create this PR to solve this more general problem first, so the |
Okay, that's good to know. I will review it again and make sure that there are no side effects. Since |
@ferblaca would it be possible to include a test case(s)? |
@ferblaca actually i played with your sample. It makes sense, so I'll merge it. You can still provide test cases as separate PR. |
…user-defined beans over binder's conditional beans in a multi-binder scenario This change modifies the loading order in DefaultBinderFactory.initializeBinderContextSimple to ensure that user configuration classes specified via spring.main.sources are loaded before binder configuration classes. This allows @ConditionalOnMissingBean annotations in the binder configurations to properly detect user-provided beans. Previously, when using KafkaBinderConfiguration with @ConditionalOnMissingBean(KafkaBinderMetrics.class), even if the user had configured a custom KafkaBinderMetrics bean via spring.main.sources, the condition would not work correctly because binder classes were loaded first. Fixes gh-3114 Signed-off-by: ferblaca <[email protected]> Resolves #3123
Ok @olegz, it'll take some time to add tests for this. In the previous PR, I looked into adding unit tests in the core module, but it wasn’t very clear how to approach it. It might be easier to verify this in an IT test for the Kafka binder module. |
Yes, it would be difficult to do it in core, so IT test in Kafka would do. Thank you!!! |
Hi @olegz, I have created PR #3127 to add the tests. Although everything compiles correctly and the tests pass locally, the PR seems to have failed in maven setup... |
@ferblaca It was a maven version issue with the CI builds, GitHub action for the PR's. I updated the version in the |
closes #3114