Skip to content

Commit 7950cac

Browse files
committed
Merge branch '3.0.x'
2 parents 052d972 + 486f100 commit 7950cac

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

spring-cloud-zookeeper-config/src/main/java/org/springframework/cloud/zookeeper/config/ZookeeperConfigDataLoader.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public ZookeeperConfigDataLoader(Log log) {
4343
public ConfigData load(ConfigDataLoaderContext context, ZookeeperConfigDataResource resource) {
4444
try {
4545
CuratorFramework curator = context.getBootstrapContext().get(CuratorFramework.class);
46+
if (curator == null) {
47+
// this can happen if certain conditions are met
48+
return null;
49+
}
4650
ZookeeperPropertySource propertySource = new ZookeeperPropertySource(resource.getContext(),
4751
curator);
4852
List<ZookeeperPropertySource> propertySources = Collections.singletonList(propertySource);
@@ -70,7 +74,7 @@ else if (ALL_OPTIONS.size() > 2) {
7074
}
7175
catch (Exception e) {
7276
if (log.isDebugEnabled()) {
73-
log.debug("Error getting properties from consul: " + resource, e);
77+
log.debug("Error getting properties from zookeeper: " + resource, e);
7478
}
7579
throw new ConfigDataResourceNotFoundException(resource, e);
7680
}

spring-cloud-zookeeper-core/src/main/java/org/springframework/cloud/zookeeper/CuratorFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ public static void registerCurator(BootstrapRegistry registery, UriComponents lo
117117
BootstrapContext context = event.getBootstrapContext();
118118
if (predicate.test(context)) {
119119
CuratorFramework curatorFramework = context.get(CuratorFramework.class);
120-
event.getApplicationContext().getBeanFactory().registerSingleton("configDataCuratorFramework",
121-
curatorFramework);
120+
if (!event.getApplicationContext().getBeanFactory().containsBean("configDataCuratorFramework")) {
121+
event.getApplicationContext().getBeanFactory().registerSingleton("configDataCuratorFramework",
122+
curatorFramework);
123+
}
122124
}
123125
});
124126

0 commit comments

Comments
 (0)