Stack Overflow question.

I think this is unexpected behavior than @DependsOn chain of ClassExtendsBeanDefinitionRegistryPostProcessor to BeanProperties breaks binding to properties. My sample classes:

@Configuration
class BeanPropertiesConfiguration {

    @Bean("beanProperties")
    @ConfigurationProperties("some.path")
    public BeanProperties basicAuthProperties() {
        return new BeanProperties();
    }
}

@Configuration
class TargetConfiguration {

    @Bean("someBeanUser")
    protected BeanUser beanUser(
            @NonNull  @Qualifier("beanProperties") BeanProperties beanProperties)
    {
        return new BeanUser(beanProperties);
    }

    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    @Bean("someBeanGenerator")
    //@DependsOn("someOtherBeanUser")  // Uncomment to break
    public ClassExtendsBeanDefinitionRegistryPostProcessor beanGenerator() {
        return new ClassExtendsBeanDefinitionRegistryPostProcessor();
    }

    @Bean("someOtherBeanUser")
    @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
    public OtherBeanUser otherBeanUser(@NonNull BeanUser beanUser) {
        return new OtherBeanUser(beanUser);
    }
}

I did't try to start up full context, but for tests with @ContextCofiguration and @ExtendWith(SpringExtension.class), beanProperties object contains null fields. (2.2.6 spring-boot release from maven repo)

Comment From: philwebb

As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Since you've already asked this question on stack overflow, let's keep the discussion there.

Comment From: Bittuw

@philwebb, I think that this is bug as I mentioned in Stack Overflow and here.

Comment From: philwebb

I've just drafted an answer to your stackoverflow question. I think this is expected behavior since you're trigger early initialization of beanUser via your ClassExtendsBeanDefinitionRegistryPostProcessor.