-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
apollo跟jasypt-spring-boot-2.1.0.jar不兼容 #2162
Comments
我这边也发现了这个问题,加入jasypt-spring-boot-2.1.0.jar后,更新配置不生效,查询源码,应该是同样的原因 |
…ppers like jasypt, so we won't be able to decide whether to trigger this change or not. So it's better just to trigger it as it is idempotent.
看了一下jasypt-spring-boot 2.1.0确实有这个问题,建议使用1.16版本,可以参考apollo-use-cases中的spring-boot-encrypt |
下面是我的一种解决方案:
} 4.自定义一个ApolloConfigChangeListener监听器,在onChange()方法中判断更新的属性值如果以“ENC(”开头则,调用第3步的类的刷新方法,刷新缓存。
} |
场景:同样的配置,两个工程。工程A无jasypt-spring-boot-2.1.0.jar依赖,工程B有。结果普通的Spring Placeholder配置,远程修改后。工程A可实时刷新,工程B不行。
原因:apollo在启动时,在PropertySourcesProcessor里,特意将自己的CompositePropertySource放在最前面,以确保在配置更新时能从environment拿到最新的配置跟远程服务通知的配置比对。在com.ctrip.framework.apollo.spring.property.AutoUpdateConfigChangeListener#shouldTriggerAutoUpdate方法中,如果从environment里拿到的配置跟远程通知的配置不同,则就算接收到了远程的通知,也不更新配置。
而jasypt-spring-boot这个jar,是在springboot工程中常用的加密敏感配置如数据库配置的jar。而jasyptspringboot的EncryptableEnumerablePropertySourceWrapper实现了PropertySource接口并代理了默认的CompositePropertySource,他的getProperty方法,走到的是com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySource的getProperty方法,是直接从一个ConcurrentMapCache的缓存中读取配置。
这样就导致在接入apollo的客户端工程里,如果引入了jasypt-spring-boot,在org.springframework.core.env.PropertySourcesPropertyResolver#getProperty方法中,由于jasypt代理了默认apollo使用的CompositePropertySource,并且将启动时的配置存入缓存,这样每次接收到远程配置变更通知时,jasypt的EncryptableEnumerablePropertySourceWrapper都会从ConcurrentMapCache的缓存中读取配置,而非从CompositePropertySource里实时读取配置,这样就会导致引入了jasypt-spring-boot的apollo客户端,无法实时更新配置。
The text was updated successfully, but these errors were encountered: