hasInstantiationAwareBeanPostProcessors()
: IMO, It is not necessary to call twice.- Before initialization BeanPostProcessorCache, if the cache is not null, the first and second method calls always return directly.
- Before initialization BeanPostProcessorCache, if the cache is null, the first method call will initialize the cache, and the second method call will still return directly.
needsDepCheck
we need to get the result when we need to use. There is a return result in the for cycle. So it is possible that we get the result but we do not use it;- use
instanceof
pattern matching
Comment From: sbrannen
Thanks for the contribution!
This has been merged into main
in e9555d482554c3f4c7b33fbf1f38591002a94857 and revised in cefd74555ada1285ecd8dc174f6dfc68115807f8.
Regarding double invocation of hasInstantiationAwareBeanPostProcessors()
, I decided to leave that in place since the state of the bean factory can change during the act of resolving autowiring candidates.
Comment From: wizard4wu
@sbrannen You think the bean factory can change during the act of resolving autowiring candidates. And i see the add the data to instantiationAware list only in the getBeanPostProcessorCache() method. When the beanPostProcessorCache is null, the code can init the BeanPostProcessorCache. So the data will add to instantiationAware list. And the instantiationAware list is only changed in the getBeanPostProcessorCache() method. When the method(hasInstantiationAwareBeanPostProcessors) is called twice, the beanPostProcessorCache must not null, because the cache has already initialized, it does not add the data to instantiationAware list. So the list does not change during the process.
If there is any misunderstanding, correct me please. I hope to receive you reply. Thanks.