Skip to content

Commit

Permalink
Register ZookeeperProperties in Bootstraper (#331)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Baxter <[email protected]>
  • Loading branch information
Ryan Baxter and ryanjbaxter authored Mar 12, 2024
1 parent 87cfa5a commit 463aaa7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.springframework.cloud.config.client.ConfigServerConfigDataLocationResolver.PropertyResolver;
import org.springframework.cloud.config.client.ConfigServerInstanceProvider;
import org.springframework.cloud.zookeeper.CuratorFactory;
import org.springframework.cloud.zookeeper.ZookeeperProperties;
import org.springframework.cloud.zookeeper.discovery.ConditionalOnZookeeperDiscoveryEnabled;
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClient;
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryProperties;
Expand Down Expand Up @@ -67,6 +68,17 @@ public void initialize(BootstrapRegistry registry) {
return;
}

//Register ZookeeperProperties instead of in CuratorFactor.registerCurator here so we can properly resolve the properties.
//We need to use the PropertyResolver to do so but that is not available in CuratorFactory since it is a class
//from Spring Cloud Config.
registry.registerIfAbsent(ZookeeperProperties.class, context -> {
if (!isEnabled(context)) {
return null;
}
PropertyResolver propertyResolver = getPropertyResolver(context);
return propertyResolver.resolveOrCreateConfigurationProperties(ZookeeperProperties.PREFIX, ZookeeperProperties.class);
});

// create curator
CuratorFactory.registerCurator(registry, null, true, ZookeeperConfigServerBootstrapper::isEnabled);

Expand Down

0 comments on commit 463aaa7

Please sign in to comment.