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

TrackedConditionEvaluator skips loading bean definitions for configuration classes that should not be skipped [SPR-17153] #21690

Open
spring-projects-issues opened this issue Aug 9, 2018 · 0 comments
Labels
in: core status: waiting-for-triage

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 9, 2018

Anastasiia Smirnova opened SPR-17153 and commented

I've found this issue while using Spring boot and files a ticket to Spring Boot:

spring-projects/spring-boot#14018

Currently we are facing a complex issue with autoconfigurations that are marked with @EnableScheduling. I have created sample project that reproduces an issue.

It consists of 4 modules:

  • library-0 module
    This module defines Library0AutoConfiguration that has @EnableScheduling and @AutoConfigureBefore(name = "org.library1.Library1AutoConfiguration"). It will not start because of unsatisfied @ConditionalOnBean (bean is not present in context).
  • library-1 module
    This module defines Library1AutoConfiguration that has @AutoConfigureBefore(name = "org.library2.Library2AutoConfiguration").
  • library-2 module
    This module defines Library2AutoConfiguration that has @EnableScheduling and @Conditional on bean of type Library1.class.
  • service module
    This module imports: library-0, library-1 and library-2 and enables autoconfiguration.
    There is test ServiceConfigurationTest that can be run to reproduce an issue:

 

@SpringBootTest(
        webEnvironment = SpringBootTest.WebEnvironment.NONE,
        classes = ServiceConfiguration.class
)
@RunWith(SpringRunner.class)
public class ServiceConfigurationTest {    @Autowired
    Library1 library1;
    @Autowired
    Library2 library2;    @Test
    public void beans_should_be_present() throws Exception {
        assertNotNull(library1);
        assertNotNull(library2);
    }
}

Actual result: both Library1AutoConfiguration and Library2AutoConfiguration should start, because they do not have dependency on Library0AutoConfiguration, but instead Library2AutoConfiguration will not start and test will fail.Removing @EnableScheduling from Library0AutoConfiguration fixes an issue.

We have found that TrackedConditionEvaluator.shouldSkip for org.springframework.scheduling.annotation.SchedulingConfiguration skips loading bean definitions for Library2AutoConfiguration.

 

Spring Boot version 1.5.13

Spring 4.3.17

 

 


Issue Links:

  • #20765 Configuration class's superclass may be incorrectly skipped if first importer isn't skipped till register bean phase of condition evaluation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: waiting-for-triage
Projects
None yet
Development

No branches or pull requests

1 participant