fix: 【framework】添加 originalConfig 字段以保存原始文件配置,修复配置变更判断逻辑
This commit is contained in:
parent
e87f4bc6cb
commit
90a4f56544
@ -19,10 +19,18 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|||||||
* 文件配置
|
* 文件配置
|
||||||
*/
|
*/
|
||||||
protected Config config;
|
protected Config config;
|
||||||
|
/**
|
||||||
|
* 原始的文件配置
|
||||||
|
*
|
||||||
|
* 原因:{@link #config} 可能被子类所修改,无法用于判断配置是否变更
|
||||||
|
* @link <a href="https://t.zsxq.com/29wkW">相关案例</a>
|
||||||
|
*/
|
||||||
|
private Config originalConfig;
|
||||||
|
|
||||||
public AbstractFileClient(Long id, Config config) {
|
public AbstractFileClient(Long id, Config config) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.originalConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,11 +48,12 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|||||||
|
|
||||||
public final void refresh(Config config) {
|
public final void refresh(Config config) {
|
||||||
// 判断是否更新
|
// 判断是否更新
|
||||||
if (config.equals(this.config)) {
|
if (config.equals(this.originalConfig)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("[refresh][配置({})发生变化,重新初始化]", config);
|
log.info("[refresh][配置({})发生变化,重新初始化]", config);
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.originalConfig = config;
|
||||||
// 初始化
|
// 初始化
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user