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
b99faba3
Commit
b99faba3
authored
Mar 13, 2018
by
darkius
Committed by
Ryan Baxter
Mar 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix management context path in URL (#2702) (#2769)
parent
57a6693d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
DefaultManagementMetadataProvider.java
...ix/eureka/metadata/DefaultManagementMetadataProvider.java
+6
-1
DefaultManagementMetadataProviderTest.java
...ureka/metadata/DefaultManagementMetadataProviderTest.java
+14
-0
No files found.
spring-cloud-netflix-eureka-client/src/main/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProvider.java
View file @
b99faba3
...
...
@@ -71,6 +71,10 @@ public class DefaultManagementMetadataProvider implements ManagementMetadataProv
private
String
refineManagementContextPath
(
String
serverContextPath
,
String
managementContextPath
,
Integer
managementPort
)
{
// management context path is relative to server context path when no management port is set
if
(
managementContextPath
!=
null
&&
managementPort
==
null
)
{
return
serverContextPath
+
managementContextPath
;
}
if
(
managementContextPath
!=
null
)
{
return
managementContextPath
;
}
...
...
@@ -86,7 +90,8 @@ public class DefaultManagementMetadataProvider implements ManagementMetadataProv
if
(!
contextPath
.
endsWith
(
"/"
))
{
contextPath
=
contextPath
+
"/"
;
}
URL
base
=
new
URL
(
scheme
,
hostname
,
port
,
contextPath
);
String
refinedContextPath
=
'/'
+
StringUtils
.
trimLeadingCharacter
(
contextPath
,
'/'
)
;
URL
base
=
new
URL
(
scheme
,
hostname
,
port
,
refinedContextPath
);
String
refinedStatusPath
=
StringUtils
.
trimLeadingCharacter
(
statusPath
,
'/'
);
return
new
URL
(
base
,
refinedStatusPath
).
toString
();
}
catch
(
MalformedURLException
e
)
{
...
...
spring-cloud-netflix-eureka-client/src/test/java/org/springframework/cloud/netflix/eureka/metadata/DefaultManagementMetadataProviderTest.java
View file @
b99faba3
...
...
@@ -108,6 +108,20 @@ public class DefaultManagementMetadataProviderTest {
Integer
managementPort
=
null
;
ManagementMetadata
actual
=
provider
.
get
(
INSTANCE
,
serverPort
,
serverContextPath
,
managementContextPath
,
managementPort
);
assertThat
(
actual
.
getHealthCheckUrl
()).
isEqualTo
(
"http://host:7777/Server/Management/health"
);
assertThat
(
actual
.
getSecureHealthCheckUrl
()).
isNullOrEmpty
();
assertThat
(
actual
.
getStatusPageUrl
()).
isEqualTo
(
"http://host:7777/Server/Management/info"
);
assertThat
(
actual
.
getManagementPort
()).
isEqualTo
(
7777
);
}
@Test
public
void
serverPortManagementContextPath
()
throws
Exception
{
int
serverPort
=
7777
;
String
serverContextPath
=
"/"
;
String
managementContextPath
=
"/Management"
;
Integer
managementPort
=
null
;
ManagementMetadata
actual
=
provider
.
get
(
INSTANCE
,
serverPort
,
serverContextPath
,
managementContextPath
,
managementPort
);
assertThat
(
actual
.
getHealthCheckUrl
()).
isEqualTo
(
"http://host:7777/Management/health"
);
assertThat
(
actual
.
getSecureHealthCheckUrl
()).
isNullOrEmpty
();
assertThat
(
actual
.
getStatusPageUrl
()).
isEqualTo
(
"http://host:7777/Management/info"
);
...
...
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