alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
29.68k stars 12.71k forks source link

为什么使用nacos-config-spring-boot-starter版本0.2.10,配置注解@NacosConfigurationProperties(autoRefreshed = true),当配置存在map类型,移除元素无效,保留的还是原来的数据 #12308

Open lints123 opened 3 weeks ago

lints123 commented 3 weeks ago

为什么nacos-config-spring-boot-starter版本0.2.10,配置注解@NacosConfigurationProperties(autoRefreshed = true),当配置存在map类型,移除元素无效,保留的还是原来的数据?

lints123 commented 3 weeks ago

nacos-client 版本是2.0.2

KomachiSion commented 2 weeks ago

其他类型数据都可以更新吗?

lints123 commented 2 weeks ago

基本数据类型可以更新,比如int,float这种,但是如果是map<String,Object>,删除元素没有效果的,新增或修改元素有效。

YunWZ commented 2 weeks ago

几年前好像遇到过类似问题, map的具体类型换成ConcurrentHashMap看看能否解决?。。。

lints123 commented 2 weeks ago

几年前好像遇到过类似问题, map的具体类型换成ConcurrentHashMap看看能否解决?。。。

不能解决,元素移除还是无效

YunWZ commented 2 weeks ago

能否提供一下复现此问题的demo?

KomachiSion commented 1 week ago

从描述上看, 配置推送是生效的, 可能是spring boot框架的限制,只能往里put(新增和覆盖),remove的话不好做。

也可能是starter实现上的问题,比如只就foreach 做put, 没有做对比移除掉不需要的key。

如果愿意帮社区排查的话,可以定位一下,然后提PR到starter仓库。