Skip to content

Register ZookeeperProperties in Bootstraper #331

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

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 @@ -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