Commit 9deab33d by Nastya Smirnova Committed by Ryan Baxter

fixes #2524 (#2574)

set proper status and health eureka urls if prefer ip address is set
parent 94358489
......@@ -135,6 +135,7 @@ public class EurekaClientAutoConfiguration {
String hostname = eurekaPropertyResolver.getProperty("hostname");
boolean preferIpAddress = Boolean.parseBoolean(eurekaPropertyResolver.getProperty("preferIpAddress"));
String ipAddress = eurekaPropertyResolver.getProperty("ipAddress");
boolean isSecurePortEnabled = Boolean.parseBoolean(eurekaPropertyResolver.getProperty("securePortEnabled"));
String serverContextPath = propertyResolver.getProperty("server.contextPath", "/");
int serverPort = Integer.valueOf(propertyResolver.getProperty("server.port", propertyResolver.getProperty("port", "8080")));
......@@ -147,6 +148,9 @@ public class EurekaClientAutoConfiguration {
instance.setNonSecurePort(serverPort);
instance.setInstanceId(getDefaultInstanceId(propertyResolver));
instance.setPreferIpAddress(preferIpAddress);
if (StringUtils.hasText(ipAddress)) {
instance.setIpAddress(ipAddress);
}
if(isSecurePortEnabled) {
instance.setSecurePort(serverPort);
......
......@@ -289,6 +289,25 @@ public class EurekaClientAutoConfigurationTests {
assertEquals("statusPageUrl is wrong", "http://" + instance.getIpAddress() + ":9999/info",
instance.getStatusPageUrl());
assertEquals("healthCheckUrl is wrong", "http://" + instance.getIpAddress() + ":9999/health",
instance.getHealthCheckUrl());
}
@Test
public void statusPageAndHealthCheckUrlsShouldSetUserDefinedIpAddress() {
addEnvironment(this.context, "server.port=8989",
"management.port=9999", "eureka.instance.hostname=foo",
"eureka.instance.ipAddress:192.168.13.90",
"eureka.instance.preferIpAddress:true");
setupContext(RefreshAutoConfiguration.class);
EurekaInstanceConfigBean instance = this.context
.getBean(EurekaInstanceConfigBean.class);
assertEquals("statusPageUrl is wrong", "http://192.168.13.90:9999/info",
instance.getStatusPageUrl());
assertEquals("healthCheckUrl is wrong", "http://192.168.13.90:9999/health",
instance.getHealthCheckUrl());
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment