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
{{ message }}
Repository navigation
Ordering issue with discovery client configuration #40
Was: DiscoveryCompositeHealthIndicatorTests#testHealthIndicator() fails with Spring 4.2.x
While researching #19, I encountered a bug in spring-boot that causes BootstrapConfigurationTests#pickupExternalBootstrapProperties() to fail on Windows. To address that failure, I have opened spring-projects/spring-boot#3299 . However, when I subsequently modify spring-cloud-build to use spring-boot 1.3.0.BUILD-SNAPSHOT it pulls in spring-beans-4.2.0.BUILD-SNAPSHOT which interprets the configuration of DiscoveryCompositeHealthIndicatorTests such that DiscoveryCompositeHealthIndicatorTests.Config#discoveryHealthIndicator() obscures CommonsClientAutoConfiguration#discoveryHealthIndicator(). So far I have determined that it's not simply a matter of the method name being duplicated, but I can't be sure whether the problem lies with spring-beans or spring-cloud-commons.
It has been several versions back since I was fairly familiar with the
startup process of a Spring ApplicationContext, but I will be continuing
to step through this test using both 4.1.6 and 4.2.0 today. I can tell you
that the CommonsClientAutoConfiguration#discoveryHealthIndicator() method
does not seem to be showing up, but it may have been a bit of a red herring
for me to say the one "producer method" obscures (by which I meant shadows) the other; the results are no different if I rename the method
in the test case configuration, but I have not yet determined where the
divergence in behavior begins.
AFAICT the fault does not lie in spring-context, but the failure occurs due to the sorting of the config beans added in spring-projects/spring-framework@f5b4e18 . CommonsClientAutoConfiguration is declared with @Order(0) but DiscoveryCompositeHealthIndicatorTests.Config has no @Order defined, and the former depends, by way of @ConditionalOnBean(DiscoveryClient.class), on the latter, which it knows nothing about once these orders (0 vs. LOWEST_PRECEDENCE) are taken into account. If I add @Order(-1) to DiscoveryCompositeHealthIndicatorTests.Config, the container starts up properly. It seems like it would kind of suck to have to change, for example, every Configuration that provides a DiscoveryClient to have a high-priority @Order but since the absence of an @Order annotation yields LOWEST_PRECEDENCE as a default the problem seemingly can't just be solved by changing the @Order of CommonsClientAutoConfiguration. Any options I haven't considered?
changed the title [-]DiscoveryCompositeHealthIndicatorTests#testHealthIndicator() fails with Spring 4.2.x[/-][+]Ordering issue with discovery client configuration[/+]on Jun 23, 2015
It depends on beans, specifically implementations of spring-cloud-commons'
DiscoveryClient interface, that are supplied by artifacts which are "lower"
in the dependency graph, i.e. they depend on spring-cloud-commons.
This can be addressed by using @AutoConfigureOrder rather than @Order on auto-configuration classes. It's new in Boot 1.3 and was added in this commit.
Activity
snicoll commentedon Jun 23, 2015
Hey, I am not sure that I understand what this problem is all about. We're about to release
4.2.0.RC2so any feedback on that would be helpful .mbenson commentedon Jun 23, 2015
It has been several versions back since I was fairly familiar with the
startup process of a Spring
ApplicationContext, but I will be continuingto step through this test using both 4.1.6 and 4.2.0 today. I can tell you
that the
CommonsClientAutoConfiguration#discoveryHealthIndicator()methoddoes not seem to be showing up, but it may have been a bit of a red herring
for me to say the one "producer method" obscures (by which I meant
shadows) the other; the results are no different if I rename the method
in the test case configuration, but I have not yet determined where the
divergence in behavior begins.
mbenson commentedon Jun 23, 2015
AFAICT the fault does not lie in
spring-context, but the failure occurs due to the sorting of the config beans added in spring-projects/spring-framework@f5b4e18 .CommonsClientAutoConfigurationis declared with@Order(0)butDiscoveryCompositeHealthIndicatorTests.Confighas no@Orderdefined, and the former depends, by way of@ConditionalOnBean(DiscoveryClient.class), on the latter, which it knows nothing about once these orders (0vs.LOWEST_PRECEDENCE) are taken into account. If I add@Order(-1)toDiscoveryCompositeHealthIndicatorTests.Config, the container starts up properly. It seems like it would kind of suck to have to change, for example, everyConfigurationthat provides aDiscoveryClientto have a high-priority@Orderbut since the absence of an@Orderannotation yieldsLOWEST_PRECEDENCEas a default the problem seemingly can't just be solved by changing the@OrderofCommonsClientAutoConfiguration. Any options I haven't considered?[-]DiscoveryCompositeHealthIndicatorTests#testHealthIndicator() fails with Spring 4.2.x[/-][+]Ordering issue with discovery client configuration[/+]snicoll commentedon Jun 24, 2015
Thanks a lot for tracking this down. I think we need to understand why
@ CommonsClientAutoConfigurationhas an@Orderdeclaration in the first place.mbenson commentedon Jun 24, 2015
wilkinsona commentedon Jun 24, 2015
This can be addressed by using
@AutoConfigureOrderrather than@Orderon auto-configuration classes. It's new in Boot 1.3 and was added in this commit.spencergibb commentedon Jun 24, 2015
@wilkinsona thanks! This will be part of spring-cloud support for boot 1.3.
mbenson commentedon Jun 24, 2015
I can confirm that this solves the reported issue, and echo thanks to @wilkinsona.
dsyer commentedon Jul 6, 2015
Fixed in daf2b8f