未验证 提交 b8a7eada 编写于 作者: J Jason Song 提交者: GitHub

Fixes #2162

For cases like #2162, there are other property source wrappers 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.
上级 05a3229e
......@@ -56,35 +56,13 @@ public class AutoUpdateConfigChangeListener implements ConfigChangeListener{
continue;
}
// 2. check whether the value is really changed or not (since spring property sources have hierarchies)
if (!shouldTriggerAutoUpdate(changeEvent, key)) {
continue;
}
// 3. update the value
// 2. update the value
for (SpringValue val : targetValues) {
updateSpringValue(val);
}
}
}
/**
* Check whether we should trigger the auto update or not.
* <br />
* For added or modified keys, we should trigger auto update if the current value in Spring equals to the new value.
* <br />
* For deleted keys, we will trigger auto update anyway.
*/
private boolean shouldTriggerAutoUpdate(ConfigChangeEvent changeEvent, String changedKey) {
ConfigChange configChange = changeEvent.getChange(changedKey);
if (configChange.getChangeType() == PropertyChangeType.DELETED) {
return true;
}
return Objects.equals(environment.getProperty(changedKey), configChange.getNewValue());
}
private void updateSpringValue(SpringValue springValue) {
try {
Object value = resolvePropertyValue(springValue);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册