Skip to content

Commit

Permalink
Support ignore refresh config (#12998)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Sep 3, 2023
1 parent e436f1e commit af56623
Showing 1 changed file with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -679,16 +684,18 @@ public void overrideWithConfig(AbstractConfig newOne, boolean overrideAll) {
* 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);
}

Expand Down Expand Up @@ -949,6 +956,17 @@ public void setDefault(Boolean isDefault) {
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 {
Expand Down

0 comments on commit af56623

Please sign in to comment.