Factory Bean, BeanDefinitionRegistryPostProcessor and XML config causes properties to not be available #33522
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: waiting-for-triage
An issue we've not yet triaged or decided on
Affects: 5.3.29, 6.1.12, probably others. I've not done an exhaustive search.
We've hit a problem with using factory beans that are constructed from XML configuration and have properties injected into them, when there is a
BeanDefinitionRegistryPostProcessor
callingBeanFactoryUtils.beanNamesForTypeIncludingAncestors
in thepostProcessBeanDefinitionRegistry
method.This sounds very specific - and it is - but this has come about because the OAuth2ClientConfiguration class from
spring-security-config
does exactly this. (Note that this didn't happen with thisOAuth2ClientConfiguration
class in Spring 5 but does in Spring 6. However, the bug as a whole reproduces in Spring 5 when I do it myself)From what we can tell, when this setup exists the factory bean is instantiated before the properties are loaded, and therefore the wrong value is provided.
Things we've also noticed:
extends AbstractFactoryBean
orimplements FactoryBean
.I've attached a Minimal reproducible example to show this happening.
properties.zip
Cheers
The text was updated successfully, but these errors were encountered: