Merge branch '3.0.x'

This commit is contained in:
spencergibb
2021-12-10 13:04:59 -05:00
2 changed files with 9 additions and 3 deletions

View File

@@ -43,6 +43,10 @@ public class ZookeeperConfigDataLoader implements ConfigDataLoader<ZookeeperConf
public ConfigData load(ConfigDataLoaderContext context, ZookeeperConfigDataResource resource) {
try {
CuratorFramework curator = context.getBootstrapContext().get(CuratorFramework.class);
if (curator == null) {
// this can happen if certain conditions are met
return null;
}
ZookeeperPropertySource propertySource = new ZookeeperPropertySource(resource.getContext(),
curator);
List<ZookeeperPropertySource> propertySources = Collections.singletonList(propertySource);
@@ -70,7 +74,7 @@ public class ZookeeperConfigDataLoader implements ConfigDataLoader<ZookeeperConf
}
catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Error getting properties from consul: " + resource, e);
log.debug("Error getting properties from zookeeper: " + resource, e);
}
throw new ConfigDataResourceNotFoundException(resource, e);
}

View File

@@ -117,8 +117,10 @@ public abstract class CuratorFactory {
BootstrapContext context = event.getBootstrapContext();
if (predicate.test(context)) {
CuratorFramework curatorFramework = context.get(CuratorFramework.class);
event.getApplicationContext().getBeanFactory().registerSingleton("configDataCuratorFramework",
curatorFramework);
if (!event.getApplicationContext().getBeanFactory().containsBean("configDataCuratorFramework")) {
event.getApplicationContext().getBeanFactory().registerSingleton("configDataCuratorFramework",
curatorFramework);
}
}
});