fuzhengwei/book-small-spring

invokeInitMethods中缺少二次初始化的判断

stanoswald opened this issue · 0 comments

AbstractAutowireCapableBeanFactory类中的invokeInitMethods函数应该像适配器的destroy函数一样,提供同时实现接口DisposableBean和添加至xml配置文件destroy-method时的判断。

参考适配器DisposableBeanAdapter的源码,是否应该将invokeInitMethods中的if条件修改如下?
if (StrUtil.isNotEmpty(initMethodName) && !(bean instanceof InitializingBean && "afterPropertiesSet".equals(initMethodName)))

书P92的注释不正确,为了避免二次销毁 应改为 为了避免二次初始化,但源码看起来已经更正了。