Skip to content

Commit 463aaa7

Browse files
Ryan Baxterryanjbaxter
andauthored
Register ZookeeperProperties in Bootstraper (#331)
Co-authored-by: Ryan Baxter <[email protected]>
1 parent 87cfa5a commit 463aaa7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/configclient/ZookeeperConfigServerBootstrapper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.cloud.config.client.ConfigServerConfigDataLocationResolver.PropertyResolver;
3636
import org.springframework.cloud.config.client.ConfigServerInstanceProvider;
3737
import org.springframework.cloud.zookeeper.CuratorFactory;
38+
import org.springframework.cloud.zookeeper.ZookeeperProperties;
3839
import org.springframework.cloud.zookeeper.discovery.ConditionalOnZookeeperDiscoveryEnabled;
3940
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClient;
4041
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties;
@@ -67,6 +68,17 @@ public void initialize(BootstrapRegistry registry) {
6768
return;
6869
}
6970

71+
//Register ZookeeperProperties instead of in CuratorFactor.registerCurator here so we can properly resolve the properties.
72+
//We need to use the PropertyResolver to do so but that is not available in CuratorFactory since it is a class
73+
//from Spring Cloud Config.
74+
registry.registerIfAbsent(ZookeeperProperties.class, context -> {
75+
if (!isEnabled(context)) {
76+
return null;
77+
}
78+
PropertyResolver propertyResolver = getPropertyResolver(context);
79+
return propertyResolver.resolveOrCreateConfigurationProperties(ZookeeperProperties.PREFIX, ZookeeperProperties.class);
80+
});
81+
7082
// create curator
7183
CuratorFactory.registerCurator(registry, null, true, ZookeeperConfigServerBootstrapper::isEnabled);
7284

0 commit comments

Comments
 (0)