Commit b8a7eada authored by Jason Song's avatar Jason Song Committed by 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.
parent 05a3229e
...@@ -56,35 +56,13 @@ public class AutoUpdateConfigChangeListener implements ConfigChangeListener{ ...@@ -56,35 +56,13 @@ public class AutoUpdateConfigChangeListener implements ConfigChangeListener{
continue; continue;
} }
// 2. check whether the value is really changed or not (since spring property sources have hierarchies) // 2. update the value
if (!shouldTriggerAutoUpdate(changeEvent, key)) {
continue;
}
// 3. update the value
for (SpringValue val : targetValues) { for (SpringValue val : targetValues) {
updateSpringValue(val); 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) { private void updateSpringValue(SpringValue springValue) {
try { try {
Object value = resolvePropertyValue(springValue); Object value = resolvePropertyValue(springValue);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment