-
Notifications
You must be signed in to change notification settings - Fork 41.2k
TestRestTemplateContextCustomizer and WebTestClientContextCustomizer can cause early FactoryBean instantiation #15898
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
Comments
Thanks for the minimal sample. We'll see what we can do, but I would recommend that you avoid injecting dependencies into a |
|
Thanks for advice about By the way, I found this behavior while using custom |
The biggest benefit of minimising the dependencies of a factory bean are when that bean is a Interestingly, when using a |
There's a change coming in Framework (thanks, @jhoeller) but we should review our use of |
Hi!
Description
A assume there is a bug in spring-boot-test, related to
TestRestTemplate
BeanDefinition
initialization.To be precise, class
TestRestTemplateContextCustomizer#TestRestTemplateRegistrar
in it's methodpostProcessBeanDefinitionRegistry
callsBeanFactoryUtils#beanNamesForTypeIncludingAncestors
.As
beanNamesForTypeIncludingAncestors
says, that's method invocation can causeFactoryBean
initialization (and their dependencies, of course). And, in context ofBeanDefinitionRegistryPostProcessor
this, I guess, is incorrect behavior.Reproducing
One file reproducer is as follows:
Note, when
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT
is commented out, test passes, as there is no need forTestRestTemplate
.Versions
The text was updated successfully, but these errors were encountered: