Skip to content

Commit

Permalink
bugfix for NacosConfigProccessor (#3903)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiyue1102 authored Nov 26, 2024
1 parent 8eebcad commit b6c5161
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ private String getGroupKeyContent(String dataId, String group) throws Exception
}
synchronized (this) {
if (!groupKeyCache.containsKey(GroupKey.getKey(dataId, group))) {
String content = nacosConfigManager.getConfigService().getConfig(dataId, group, 5000);
String content = getNacosConfigManager().getConfigService().getConfig(dataId, group, 5000);
groupKeyCache.put(GroupKey.getKey(dataId, group), new AtomicReference<>(content));

log.info("[Nacos Config] Listening config for annotation: dataId={}, group={}", dataId,
group);
nacosConfigManager.getConfigService().addListener(dataId, group, new AbstractListener() {
getNacosConfigManager().getConfigService().addListener(dataId, group, new AbstractListener() {
@Override
public void receiveConfigInfo(String s) {
groupKeyCache.get(GroupKey.getKey(dataId, group)).set(s);
Expand All @@ -105,7 +105,8 @@ public String toString() {

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
return bean;
}

@Override
Expand Down Expand Up @@ -223,7 +224,7 @@ public String toString() {
};
}

nacosConfigManager.getConfigService()
getNacosConfigManager().getConfigService()
.addListener(dataId, group, listener);
targetListenerMap.put(refreshTargetKey, listener);

Expand Down Expand Up @@ -270,7 +271,7 @@ public String toString() {
}
};
nacosPropertiesKeyListener.setLastContent(getGroupKeyContent(dataId, group));
nacosConfigManager.getConfigService().addListener(dataId, group,
getNacosConfigManager().getConfigService().addListener(dataId, group,
nacosPropertiesKeyListener);
targetListenerMap.put(refreshTargetKey, nacosPropertiesKeyListener);
}
Expand Down Expand Up @@ -382,7 +383,7 @@ public String toString() {
};
}

nacosConfigManager.getConfigService().addListener(dataId, group, listener);
getNacosConfigManager().getConfigService().addListener(dataId, group, listener);
targetListenerMap.put(refreshTargetKey, listener);
if (annotation.initNotify() && org.springframework.util.StringUtils.hasText(configInfo)) {
try {
Expand Down Expand Up @@ -519,7 +520,7 @@ public String toString() {
};
}

nacosConfigManager.getConfigService()
getNacosConfigManager().getConfigService()
.addListener(dataId, group, listener);
targetListenerMap.put(refreshTargetKey, listener);

Expand Down Expand Up @@ -604,7 +605,7 @@ public String toString() {
};
}

nacosConfigManager.getConfigService()
getNacosConfigManager().getConfigService()
.addListener(dataId, group, listener);
targetListenerMap.put(refreshTargetKey, listener);
return true;
Expand Down Expand Up @@ -739,7 +740,14 @@ private void handleMethodAnnotation(final Object bean, String beanName, final Me
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
nacosConfigManager = this.applicationContext.getBean(NacosConfigManager.class);
}

private NacosConfigManager getNacosConfigManager() {
if (this.nacosConfigManager == null) {
nacosConfigManager = this.applicationContext.getBean(NacosConfigManager.class);

}
return nacosConfigManager;
}

private static String[] getNullPropertyNames(Object source) {
Expand Down

0 comments on commit b6c5161

Please sign in to comment.