Skip to content

Ordering issue with discovery client configuration #40

Closed

Description

@mbenson

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.

Activity

  1. snicoll commented on Jun 23, 2015

    @snicoll
    Contributor

    Hey, I am not sure that I understand what this problem is all about. We're about to release 4.2.0.RC2 so any feedback on that would be helpful .

  2. mbenson commented on Jun 23, 2015

    @mbenson
    ContributorAuthor

    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.

  3. mbenson commented on Jun 23, 2015

    @mbenson
    ContributorAuthor

    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?

  4. changed the title [-]DiscoveryCompositeHealthIndicatorTests#testHealthIndicator() fails with Spring 4.2.x[/-] [+]Ordering issue with discovery client configuration[/+] on Jun 23, 2015
  5. snicoll commented on Jun 24, 2015

    @snicoll
    Contributor

    Thanks a lot for tracking this down. I think we need to understand why @ CommonsClientAutoConfiguration has an @Order declaration in the first place.

  6. mbenson commented on Jun 24, 2015

    @mbenson
    ContributorAuthor
  7. wilkinsona commented on Jun 24, 2015

    @wilkinsona
    Contributor

    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.

  8. spencergibb commented on Jun 24, 2015

    @spencergibb
    Member

    @wilkinsona thanks! This will be part of spring-cloud support for boot 1.3.

  9. mbenson commented on Jun 24, 2015

    @mbenson
    ContributorAuthor

    I can confirm that this solves the reported issue, and echo thanks to @wilkinsona.

  10. dsyer commented on Jul 6, 2015

    @dsyer
    Contributor

    Fixed in daf2b8f

  11. added this to the 1.1.0 milestone on Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions