DerekYRC / mini-spring

mini-spring是简化版的spring框架,能帮助你快速熟悉spring源码和掌握spring的核心原理。抽取了spring的核心逻辑,代码极度简化,保留spring的核心功能,如IoC和AOP、资源加载器、事件监听器、类型转换、容器扩展点、bean生命周期和作用域、应用上下文等核心功能。

Home Page:https://github.com/DerekYRC/mini-spring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

auto-proxy 代理对象创建时,没有设置被代理对象的属性bug

kerwin89 opened this issue · comments

可以帮忙修复一下吗?或者我周末有时间看看

@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的返回值
企业微信截图_1609242036974
3、补充单侧
4、changlog.md中简单描述下改动点

尝试着修复了一下哈