Signed-off-by: Eric Zhao <sczyh16@gmail.com>master
@@ -46,9 +46,9 @@ public class DynamicSentinelProperty<T> implements SentinelProperty<T> { | |||||
} | } | ||||
@Override | @Override | ||||
public void updateValue(T newValue) { | |||||
public boolean updateValue(T newValue) { | |||||
if (isEqual(value, newValue)) { | if (isEqual(value, newValue)) { | ||||
return; | |||||
return false; | |||||
} | } | ||||
RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); | RecordLog.info("[DynamicSentinelProperty] Config will be updated to: " + newValue); | ||||
@@ -56,7 +56,7 @@ public class DynamicSentinelProperty<T> implements SentinelProperty<T> { | |||||
for (PropertyListener<T> listener : listeners) { | for (PropertyListener<T> listener : listeners) { | ||||
listener.configUpdate(newValue); | listener.configUpdate(newValue); | ||||
} | } | ||||
return true; | |||||
} | } | ||||
private boolean isEqual(T oldValue, T newValue) { | private boolean isEqual(T oldValue, T newValue) { | ||||
@@ -21,6 +21,7 @@ package com.alibaba.csp.sentinel.property; | |||||
* @author leyou | * @author leyou | ||||
*/ | */ | ||||
public final class NoOpSentinelProperty implements SentinelProperty<Object> { | public final class NoOpSentinelProperty implements SentinelProperty<Object> { | ||||
@Override | @Override | ||||
public void addListener(PropertyListener<Object> listener) { } | public void addListener(PropertyListener<Object> listener) { } | ||||
@@ -28,5 +29,7 @@ public final class NoOpSentinelProperty implements SentinelProperty<Object> { | |||||
public void removeListener(PropertyListener<Object> listener) { } | public void removeListener(PropertyListener<Object> listener) { } | ||||
@Override | @Override | ||||
public void updateValue(Object newValue) { } | |||||
public boolean updateValue(Object newValue) { | |||||
return true; | |||||
} | |||||
} | } |
@@ -56,6 +56,7 @@ public interface SentinelProperty<T> { | |||||
* added on this only when new {@code newValue} is not Equals to the old value. | * added on this only when new {@code newValue} is not Equals to the old value. | ||||
* | * | ||||
* @param newValue the new value. | * @param newValue the new value. | ||||
* @return true if the value in property has been updated, otherwise false | |||||
*/ | */ | ||||
void updateValue(T newValue); | |||||
boolean updateValue(T newValue); | |||||
} | } |