Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

properties类型文件,在自定义监听器ConfigChangeListener#onChange中调用ConfigFile.getContent获取的内容是上一次修改的旧值 #4545

Closed
3 tasks done
yanhom1314 opened this issue Sep 1, 2022 · 4 comments
Labels

Comments

@yanhom1314
Copy link

yanhom1314 commented Sep 1, 2022

描述bug

properties类型文件,在自定义监听器ConfigChangeListener#onChange中调用ConfigFile.getContent获取的内容是上一次修改的旧值。
调试源码发现顺序是先调用监听器ConfigChangeListener#onChange,然后在调用AbstractConfigFile#onRepositoryChange来实现newProperties的赋值,所以会有这个问题,如果顺序调转下就没问题了,不清楚apollo就是这样设计的还是bug

复现

通过如下步骤可以复现:

  1. 自定义监听器实现ConfigChangeListener接口
  2. 配置properties类型配置文件
  3. 多次更改配置项值,在onChange方法中通过ConfigFile#getContent获取到的是上一次的值,不是最新的

期望

获取到最新的值

截图

image

额外的细节和日志

  • 版本:1.9.1
  • 错误日志
  • 配置:
  • 平台和操作系统
@nobodyiam
Copy link
Member

ConfigFile 需要通过 ConfigFileChangeEvent 来获取更新事件。

@yanhom1314
Copy link
Author

了解了,感谢大佬

@stale
Copy link

stale bot commented Oct 4, 2022

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2022
@stale
Copy link

stale bot commented Oct 14, 2022

This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants