Commit 90a4f56544da2b5006a44e692bbdf34d8242a059
1 parent
e87f4bc6
fix: 【framework】添加 originalConfig 字段以保存原始文件配置,修复配置变更判断逻辑
Showing
1 changed file
with
10 additions
and
1 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/client/AbstractFileClient.java
| ... | ... | @@ -19,10 +19,18 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem |
| 19 | 19 | * 文件配置 |
| 20 | 20 | */ |
| 21 | 21 | protected Config config; |
| 22 | + /** | |
| 23 | + * 原始的文件配置 | |
| 24 | + * | |
| 25 | + * 原因:{@link #config} 可能被子类所修改,无法用于判断配置是否变更 | |
| 26 | + * @link <a href="https://t.zsxq.com/29wkW">相关案例</a> | |
| 27 | + */ | |
| 28 | + private Config originalConfig; | |
| 22 | 29 | |
| 23 | 30 | public AbstractFileClient(Long id, Config config) { |
| 24 | 31 | this.id = id; |
| 25 | 32 | this.config = config; |
| 33 | + this.originalConfig = config; | |
| 26 | 34 | } |
| 27 | 35 | |
| 28 | 36 | /** |
| ... | ... | @@ -40,11 +48,12 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem |
| 40 | 48 | |
| 41 | 49 | public final void refresh(Config config) { |
| 42 | 50 | // 判断是否更新 |
| 43 | - if (config.equals(this.config)) { | |
| 51 | + if (config.equals(this.originalConfig)) { | |
| 44 | 52 | return; |
| 45 | 53 | } |
| 46 | 54 | log.info("[refresh][配置({})发生变化,重新初始化]", config); |
| 47 | 55 | this.config = config; |
| 56 | + this.originalConfig = config; | |
| 48 | 57 | // 初始化 |
| 49 | 58 | this.init(); |
| 50 | 59 | } | ... | ... |