Create InetUtils in default ConsulDiscoveryProperties constructor.
Fixes gh-683
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.cloud.commons.util.InetUtils.HostInfo;
|
||||
import org.springframework.cloud.commons.util.InetUtilsProperties;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
|
||||
/**
|
||||
@@ -207,11 +208,11 @@ public class ConsulDiscoveryProperties {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ConsulDiscoveryProperties() {
|
||||
this.managementTags.add(MANAGEMENT);
|
||||
this(new InetUtils(new InetUtilsProperties()));
|
||||
}
|
||||
|
||||
public ConsulDiscoveryProperties(InetUtils inetUtils) {
|
||||
this();
|
||||
this.managementTags.add(MANAGEMENT);
|
||||
this.hostInfo = inetUtils.findFirstNonLoopbackHostInfo();
|
||||
this.ipAddress = this.hostInfo.getIpAddress();
|
||||
this.hostname = this.hostInfo.getHostname();
|
||||
|
||||
@@ -55,6 +55,7 @@ public class ConsulConfigServerBootstrapperTests {
|
||||
BindHandlerBootstrapper bindHandlerBootstrapper = new BindHandlerBootstrapper();
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestConfig.class)
|
||||
.properties("--server.port=0", "spring.cloud.config.discovery.enabled=true",
|
||||
"spring.cloud.consul.discovery.hostname=myhost",
|
||||
"spring.cloud.service-registry.auto-registration.enabled=false",
|
||||
"spring.cloud.consul.host=localhost")
|
||||
.addBootstrapper(bindHandlerBootstrapper)
|
||||
|
||||
Reference in New Issue
Block a user