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
Beans produced by @EachBean based on a certain Bean should maintain the original's Bean @Order attribute, if defined. BeanDefinitionDelegate does not delegate getOrder() to its originating Bean.
For example, a Jdbi instance created over a DataSource which is @Order(-1000) does not report the same order and so if there are more DataSources, the implied Jdbi beans cause ambiguity on injection
Actual Behaviour
All Beans implied by @EachBean should maintain the original's bean @Order.
Steps To Reproduce
Build the example application from the repository, run the test, observe the failure
Detailed information:
I have a configuration-defined DataSource in my application. Currently using legacy dropwizard structure of configurations with includes, the datasource is defined at a more base level. There's no way how I can replace the @Named("default") DataSource, as it is @Primary at the same time. If I declare a @Bean in my test that produces @Primary data source, the test will throw on initialization because there are two @Primary beans the other comes from @EachProperty iterating over datasources.* which assigns the object resulting from .default subtree as @Primary.
Last, I've tried to @Order this test implementation to give it a priority - but the dynamic registration of EachProperty or EachBean does not delegate to the original bean definition's Order attribute, so even this way how to prioritize testing DataSource fails.
I suggest to
enhance the implied BeanDefinitionDelegate to delegate getOrder() to its delegate's value. This could be beneficial even for other cases, where wrappers or derivative beans are created, since they would maintain their original's priorities.
@EachProperty could be enhanced with "enabled" attribute to look for an explicit enabled sub-property (default name "enabled", default value: true). This luckily works specifically in DataSourceConfiguration so I used that as a workaround
The @Property annotation on tests could support removing of property subtree - e.g. remove attribute exclusive with value. In my case the test could erase specific datasource's configuration.
Maybe suggestions (2) and (3) should be filed as separate enhancement requests ?
Expected Behavior
Beans produced by
@EachBean
based on a certain Bean should maintain the original's Bean@Order
attribute, if defined.BeanDefinitionDelegate
does not delegategetOrder()
to its originating Bean.For example, a
Jdbi
instance created over a DataSource which is@Order(-1000)
does not report the same order and so if there are more DataSources, the impliedJdbi
beans cause ambiguity on injectionActual Behaviour
All Beans implied by
@EachBean
should maintain the original's bean@Order
.Steps To Reproduce
Detailed information:
I have a configuration-defined DataSource in my application. Currently using legacy dropwizard structure of configurations with includes, the datasource is defined at a more base level. There's no way how I can replace the
@Named("default") DataSource
, as it is@Primary
at the same time. If I declare a@Bean
in my test that produces@Primary
data source, the test will throw on initialization because there are two@Primary
beans the other comes from@EachProperty
iterating overdatasources.*
which assigns the object resulting from.default
subtree as@Primary
.Last, I've tried to
@Order
this test implementation to give it a priority - but the dynamic registration of EachProperty or EachBean does not delegate to the original bean definition's Order attribute, so even this way how to prioritize testing DataSource fails.I suggest to
BeanDefinitionDelegate
to delegategetOrder()
to its delegate's value. This could be beneficial even for other cases, where wrappers or derivative beans are created, since they would maintain their original's priorities.@EachProperty
could be enhanced with "enabled" attribute to look for an explicit enabled sub-property (default name "enabled", default value: true). This luckily works specifically inDataSourceConfiguration
so I used that as a workaround@Property
annotation on tests could support removing of property subtree - e.g.remove
attribute exclusive withvalue
. In my case the test could erase specific datasource's configuration.Maybe suggestions (2) and (3) should be filed as separate enhancement requests ?
Environment Information
Example Application
https://github.com/sdedic/micronaut-eachbean-bug
Version
4.6.0 4.6.5
The text was updated successfully, but these errors were encountered: