Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
yanrongzhen opened this issue Mar 21, 2023 · 0 comments · Fixed by #1135
Closed

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

yanrongzhen opened this issue Mar 21, 2023 · 0 comments · Fixed by #1135
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@yanrongzhen
Copy link
Member

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

yanrongzhen added a commit to yanrongzhen/hippo4j that referenced this issue Mar 21, 2023
@magestacks magestacks added the type: bug Something isn't working label Mar 24, 2023
@magestacks magestacks added this to the 1.5.0 milestone Mar 24, 2023
magestacks pushed a commit that referenced this issue Apr 11, 2023
…ool under the Config mode. (#1133)

* Add notification logic after modifying web thread pool parameters.

* Refactor the notification module to enable notification capability for the web container.

* Add application profile enum.

* Revert the bugfix changes and split them into issue #1134.

* Revert @order annotation in AbstractWebThreadPoolService.

* fix profile enum name with test environment.

* Fix: remove unused imports.

* Delete ProfileEnum class.

* Modify the way of obtaining the ID of the web thread pool.

* Move the IExecutorProperties class to the common module.

* Narrow the scope of @SuppressWarnings annotation usage.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants