Skip to content

Web容器启动时刷新最新配置失败 #1134

Closed
@yanrongzhen

Description

@yanrongzhen

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容器线程池为空, 报空指针异常, 刷新失败.

问题重现步骤

  1. 设置apollo.bootstrap.enabled=true, 启动时自动从配置中心拉取最新配置
  2. 启动config模式, 触发RefreshEvent后, 在 WebExecutorRefreshListener当中调用cn.hippo4j.adapter.web.WebThreadPoolService#getWebThreadPoolParameter方法会出现NPE异常

解决方案

使用@order注解, 指定获取Web容器线程池的AbstractWebThreadPoolService为最先执行的ApplicationRunner

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions