Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
9deab33d
Commit
9deab33d
authored
Jan 02, 2018
by
Nastya Smirnova
Committed by
Ryan Baxter
Jan 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes #2524 (#2574)
set proper status and health eureka urls if prefer ip address is set
parent
94358489
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
EurekaClientAutoConfiguration.java
...k/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
+4
-0
EurekaClientAutoConfigurationTests.java
...ud/netflix/eureka/EurekaClientAutoConfigurationTests.java
+19
-0
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration.java
View file @
9deab33d
...
...
@@ -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
);
...
...
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/EurekaClientAutoConfigurationTests.java
View file @
9deab33d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment