This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
Bean definition extending FactoryBean with generics is not injected #1022
Labels
status: superseded
An issue that has been superseded by another
This problem can be seen with the
hateoas
anddata-rest
samples currently.They're both contributing
PluginRegistry<T,S>
beans throughPluginRegistryFactoryBean<T,S>
declared as bean definitions.Samples fails with the following:
While debugging the issue, we've found that the current code generation process contributes that definition to the context with:
Declaring the
FactoryBean
type as theResolvableType
target type in the definition seems to confuse the core container in theorg.springframework.beans.factory.support.DefaultListableBeanFactory#doResolveDependency
and especially theorg.springframework.beans.factory.support.DefaultListableBeanFactory#findAutowireCandidates
sequence. Instead of considering the generic type of the bean produced by theFactoryBean
and if it's assignable to the required type for the injection point, this seems to only consider the provided target type.This might be linked with the fact that we're heavily using the
instanceSupplier
mechanism instead of factory methods.We've validated that tweaking the targetType to represent the actual type produced by the
FactoryBean
fixes the issue, but this might not be in line with the expected API usage. This should be discussed in a Spring Framework issue (to be linked here).The text was updated successfully, but these errors were encountered: