Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
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-boot-admin
Commits
e8d80584
Commit
e8d80584
authored
Oct 11, 2016
by
weeniearms
Committed by
Johannes Edmeier
Oct 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use hostname of server/management.adress if set
If server.address or management.adress is set use it's value to resolve the hostname used for management-/service-url.
parent
03624266
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
11 deletions
+36
-11
AdminClientProperties.java
.../codecentric/boot/admin/config/AdminClientProperties.java
+9
-11
AdminClientPropertiesTest.java
...ecentric/boot/admin/config/AdminClientPropertiesTest.java
+27
-0
No files found.
spring-boot-admin-starter-client/src/main/java/de/codecentric/boot/admin/config/AdminClientProperties.java
View file @
e8d80584
...
...
@@ -95,16 +95,16 @@ public class AdminClientProperties {
"serviceUrl must be set when deployed to servlet-container"
);
}
InetAddress
address
=
management
.
getAddress
();
if
(
address
==
null
)
{
address
=
getHostAddress
();
}
if
(
preferIp
)
{
InetAddress
address
=
management
.
getAddress
();
if
(
address
==
null
)
{
address
=
getHostAddress
();
}
return
append
(
append
(
createLocalUri
(
address
.
getHostAddress
(),
managementPort
),
server
.
getContextPath
()),
management
.
getContextPath
());
}
return
append
(
createLocalUri
(
getHostAddress
()
.
getCanonicalHostName
(),
managementPort
),
return
append
(
createLocalUri
(
address
.
getCanonicalHostName
(),
managementPort
),
management
.
getContextPath
());
}
...
...
@@ -133,16 +133,13 @@ public class AdminClientProperties {
"serviceUrl must be set when deployed to servlet-container"
);
}
InetAddress
address
=
getHostAddress
();
if
(
preferIp
)
{
InetAddress
address
=
server
.
getAddress
();
if
(
address
==
null
)
{
address
=
getHostAddress
();
}
return
append
(
createLocalUri
(
address
.
getHostAddress
(),
serverPort
),
server
.
getContextPath
());
}
return
append
(
createLocalUri
(
getHostAddress
()
.
getCanonicalHostName
(),
serverPort
),
return
append
(
createLocalUri
(
address
.
getCanonicalHostName
(),
serverPort
),
server
.
getContextPath
());
}
...
...
@@ -183,7 +180,8 @@ public class AdminClientProperties {
private
InetAddress
getHostAddress
()
{
try
{
return
InetAddress
.
getLocalHost
();
InetAddress
address
=
server
.
getAddress
();
return
address
!=
null
?
address
:
InetAddress
.
getLocalHost
();
}
catch
(
UnknownHostException
ex
)
{
throw
new
IllegalArgumentException
(
ex
.
getMessage
(),
ex
);
}
...
...
spring-boot-admin-starter-client/src/test/java/de/codecentric/boot/admin/config/AdminClientPropertiesTest.java
View file @
e8d80584
...
...
@@ -173,6 +173,33 @@ public class AdminClientPropertiesTest {
assertThat
(
clientProperties
.
getServiceUrl
(),
is
(
"http://127.0.0.1:8080"
));
}
@Test
public
void
test_serveraddress
()
{
load
(
"server.address=127.0.0.2"
,
"local.server.port=8080"
);
AdminClientProperties
clientProperties
=
new
AdminClientProperties
();
context
.
getAutowireCapableBeanFactory
().
autowireBean
(
clientProperties
);
publishApplicationReadyEvent
(
clientProperties
);
assertThat
(
clientProperties
.
getServiceUrl
(),
is
(
"http://127.0.0.2:8080"
));
assertThat
(
clientProperties
.
getManagementUrl
(),
is
(
"http://127.0.0.2:8080"
));
assertThat
(
clientProperties
.
getHealthUrl
(),
is
(
"http://127.0.0.2:8080/health"
));
}
@Test
public
void
test_managementaddress
()
{
load
(
"server.address=127.0.0.2"
,
"management.address=127.0.0.3"
,
"local.server.port=8080"
,
"local.management.port=8081"
);
AdminClientProperties
clientProperties
=
new
AdminClientProperties
();
context
.
getAutowireCapableBeanFactory
().
autowireBean
(
clientProperties
);
publishApplicationReadyEvent
(
clientProperties
);
assertThat
(
clientProperties
.
getServiceUrl
(),
is
(
"http://127.0.0.2:8080"
));
assertThat
(
clientProperties
.
getManagementUrl
(),
is
(
"http://127.0.0.3:8081"
));
assertThat
(
clientProperties
.
getHealthUrl
(),
is
(
"http://127.0.0.3:8081/health"
));
}
private
String
getHostname
()
{
try
{
return
InetAddress
.
getLocalHost
().
getCanonicalHostName
();
...
...
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