mini-spring
mini-spring copied to clipboard
auto-proxy 代理对象创建时,没有设置被代理对象的属性bug
可以帮忙修复一下吗?或者我周末有时间看看
@DerekYRC 查看了spring源码,InstantiationAwareBeanPostProcessor 源码还有两个接口没有实现。这个也不算bug吧,毕竟是mini版。写的不错,赞👍 boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException; PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException;
@kerwin89 非常感谢你的肯定,很开心你能这么认真读到这。 这确实是个问题,刚刚debug代码后才知道,织入操作不应该放在InstantiationAwareBeanPostProcessor#postProcessBeforeInstantiation,而应该放在BeanPostProcessor#postProcessAfterInitialization。 初步的修复方案如下,如果你有兴趣的可以帮忙在populate-proxy-bean-with-property-values分支修复该bug
1、DefaultAdvisorAutoProxyCreator#postProcessBeforeInstantiation的内容挪到postProcessAfterInitialization方法中,postProcessBeforeInstantiation返回null
2、用bean接受AbstractAutowireCapableBeanFactory#initializeBean的返回值
3、补充单侧
4、changlog.md中简单描述下改动点
尝试着修复了一下哈
“没有为代理bean设置属性” 这个标题有歧义,感觉改成“没有为被代理bean设置属性”会好一点