Support ignore refresh config (#12998)

This commit is contained in:
Albumen Kevin 2023-09-03 10:36:26 +08:00 committed by GitHub
parent e436f1eee9
commit af566233db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 9 deletions

View File

@ -103,6 +103,11 @@ public abstract class AbstractConfig implements Serializable {
protected final AtomicBoolean refreshed = new AtomicBoolean(false);
/**
* Indicate that if current config needs to being refreshed, default is true
*/
protected transient volatile boolean needRefresh = true;
/**
* Is default config or not
*/
@ -679,16 +684,18 @@ public abstract class AbstractConfig implements Serializable {
* Dubbo config property override
*/
public void refresh() {
try {
// check and init before do refresh
preProcessRefresh();
refreshWithPrefixes(getPrefixes(), getConfigMode());
} catch (Exception e) {
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, e);
throw new IllegalStateException("Failed to override field value of config bean: " + this, e);
}
if (needRefresh) {
try {
// check and init before do refresh
preProcessRefresh();
refreshWithPrefixes(getPrefixes(), getConfigMode());
} catch (Exception e) {
logger.error(COMMON_FAILED_OVERRIDE_FIELD, "", "", "Failed to override field value of config bean: " + this, e);
throw new IllegalStateException("Failed to override field value of config bean: " + this, e);
}
postProcessRefresh();
postProcessRefresh();
}
refreshed.set(true);
}
@ -949,6 +956,17 @@ public abstract class AbstractConfig implements Serializable {
this.isDefault = isDefault;
}
@Transient
@Parameter(excluded = true, attribute = false)
public boolean isNeedRefresh() {
return needRefresh;
}
@Transient
public void setNeedRefresh(boolean needRefresh) {
this.needRefresh = needRefresh;
}
@Override
public String toString() {
try {