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
6c52269d
Commit
6c52269d
authored
Nov 27, 2017
by
saga
Committed by
Ryan Baxter
Nov 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Associated with this PR # 2466 (#2470)
Use StringBuffer for String concatenation
parent
736a3e46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
EurekaController.java
...amework/cloud/netflix/eureka/server/EurekaController.java
+4
-3
EurekaControllerReplicasTests.java
.../netflix/eureka/server/EurekaControllerReplicasTests.java
+29
-0
No files found.
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaController.java
View file @
6c52269d
...
...
@@ -49,6 +49,7 @@ import com.netflix.eureka.util.StatusInfo;
/**
* @author Spencer Gibb
* @author Gang Li
*/
@Controller
@RequestMapping
(
"${eureka.dashboard.path:/}"
)
...
...
@@ -287,12 +288,12 @@ public class EurekaController {
private
String
scrubBasicAuth
(
String
urlList
){
String
[]
urls
=
urlList
.
split
(
","
);
String
filteredUrls
=
""
;
String
Builder
filteredUrls
=
new
StringBuilder
()
;
for
(
String
u
:
urls
){
if
(
u
.
contains
(
"@"
)){
filteredUrls
+=
u
.
substring
(
0
,
u
.
indexOf
(
"//"
)+
2
)+
u
.
substring
(
u
.
indexOf
(
"@"
)+
1
,
u
.
length
())+
","
;
filteredUrls
.
append
(
u
.
substring
(
0
,
u
.
indexOf
(
"//"
)+
2
)).
append
(
u
.
substring
(
u
.
indexOf
(
"@"
)+
1
,
u
.
length
())).
append
(
","
)
;
}
else
{
filteredUrls
+=
u
+
","
;
filteredUrls
.
append
(
u
).
append
(
","
)
;
}
}
return
filteredUrls
.
substring
(
0
,
filteredUrls
.
length
()-
1
);
...
...
spring-cloud-netflix-eureka-server/src/test/java/org/springframework/cloud/netflix/eureka/server/EurekaControllerReplicasTests.java
View file @
6c52269d
...
...
@@ -23,6 +23,15 @@ public class EurekaControllerReplicasTests {
String
authList1
=
"http://user:pwd@test1.com"
;
String
authList2
=
authList1
+
",http://user2:pwd2@test2.com"
;
String
combinationAuthList1
=
"http://test1.com,http://user2:pwd2@test2.com"
;
String
combinationAuthList2
=
"http://test3.com,http://user4:pwd4@test4.com"
;
String
combinationNoAuthList1
=
"http://test1.com,http://test2.com"
;
String
combinationNoAuthList2
=
"http://test3.com,http://test4.com"
;
String
totalAutoList
=
combinationAuthList1
+
","
+
combinationAuthList2
;
String
totalNoAutoList
=
combinationNoAuthList1
+
","
+
combinationNoAuthList2
;
String
empty
=
new
String
();
private
ApplicationInfoManager
original
;
...
...
@@ -81,4 +90,24 @@ public class EurekaControllerReplicasTests {
}
@Test
public
void
testFilterReplicasAuthWithCombinationList
()
throws
Exception
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
StatusInfo
statusInfo
=
StatusInfo
.
Builder
.
newBuilder
()
.
add
(
"registered-replicas"
,
totalAutoList
)
.
add
(
"available-replicas"
,
combinationAuthList1
)
.
add
(
"unavailable-replicas"
,
combinationAuthList2
)
.
withInstanceInfo
(
instanceInfo
).
build
();
EurekaController
controller
=
new
EurekaController
(
null
);
controller
.
filterReplicas
(
model
,
statusInfo
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
String
>
results
=
(
Map
<
String
,
String
>)
model
.
get
(
"applicationStats"
);
assertEquals
(
totalNoAutoList
,
results
.
get
(
"registered-replicas"
));
assertEquals
(
combinationNoAuthList1
,
results
.
get
(
"available-replicas"
));
assertEquals
(
combinationNoAuthList2
,
results
.
get
(
"unavailable-replicas"
));
}
}
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