Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for NacosConfigProccessor #3903

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,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 @@ -101,7 +101,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 @@ -219,7 +220,7 @@ public String toString() {
};
}

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

Expand Down Expand Up @@ -266,7 +267,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 @@ -378,7 +379,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 @@ -515,7 +516,7 @@ public String toString() {
};
}

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

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

nacosConfigManager.getConfigService()
getNacosConfigManager().getConfigService()
.addListener(dataId, group, listener);
targetListenerMap.put(refreshTargetKey, listener);
return true;
Expand Down Expand Up @@ -735,6 +736,13 @@ 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;
}
}
Loading