Closed
Description
BUG 报告
你使用了哪个项目?
hippo4j config
你使用了哪个版本?
1.5.0-SNAPSHOT
预期行为
内存中Web Executor 成功更新至最新参数
实际行为
空指针
原因分析(如果可以)
cn.hippo4j.adapter.web.AbstractWebThreadPoolService
类实现了ApplicationRunner, 用于在启动后(run方法)从上下文当中获取嵌入式Web容器, 再获取其中的线程池. 但是由于没有指定优先级, 比
cn.hippo4j.config.springboot.starter.refresher.AbstractConfigThreadPoolDynamicRefresh
执行的晚, 导致在启动时收到配置变更信息时, cn.hippo4j.adapter.web.AbstractWebThreadPoolService
当中的web容器线程池为空, 报空指针异常, 刷新失败.
问题重现步骤
- 设置apollo.bootstrap.enabled=true, 启动时自动从配置中心拉取最新配置
- 启动config模式, 触发RefreshEvent后, 在
WebExecutorRefreshListener
当中调用cn.hippo4j.adapter.web.WebThreadPoolService#getWebThreadPoolParameter
方法会出现NPE异常
解决方案
使用@order注解, 指定获取Web容器线程池的AbstractWebThreadPoolService
为最先执行的ApplicationRunner