|
|
@@ -19,10 +19,18 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|
|
* 文件配置
|
|
|
*/
|
|
|
protected Config config;
|
|
|
+ /**
|
|
|
+ * 原始的文件配置
|
|
|
+ *
|
|
|
+ * 原因:{@link #config} 可能被子类所修改,无法用于判断配置是否变更
|
|
|
+ * @link <a href="https://t.zsxq.com/29wkW">相关案例</a>
|
|
|
+ */
|
|
|
+ private Config originalConfig;
|
|
|
|
|
|
public AbstractFileClient(Long id, Config config) {
|
|
|
this.id = id;
|
|
|
this.config = config;
|
|
|
+ this.originalConfig = config;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -40,11 +48,12 @@ public abstract class AbstractFileClient<Config extends FileClientConfig> implem
|
|
|
|
|
|
public final void refresh(Config config) {
|
|
|
// 判断是否更新
|
|
|
- if (config.equals(this.config)) {
|
|
|
+ if (config.equals(this.originalConfig)) {
|
|
|
return;
|
|
|
}
|
|
|
log.info("[refresh][配置({})发生变化,重新初始化]", config);
|
|
|
this.config = config;
|
|
|
+ this.originalConfig = config;
|
|
|
// 初始化
|
|
|
this.init();
|
|
|
}
|