Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
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
DEMO
spring-boot
Commits
a83852b7
Commit
a83852b7
authored
Oct 29, 2019
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consistently clean actuator endpoint ids
Closes gh-18649
parent
d6d32ec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
IncludeExcludeGroupMemberPredicate.java
...oconfigure/health/IncludeExcludeGroupMemberPredicate.java
+3
-2
IncludeExcludeGroupMemberPredicateTests.java
...igure/health/IncludeExcludeGroupMemberPredicateTests.java
+18
-0
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicate.java
View file @
a83852b7
...
...
@@ -20,6 +20,7 @@ import java.util.Collections;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
/**
* Member predicate that matches based on {@code include} and {@code exclude} sets.
...
...
@@ -54,12 +55,12 @@ class IncludeExcludeGroupMemberPredicate implements Predicate<String> {
if
(
names
==
null
)
{
return
Collections
.
emptySet
();
}
Set
<
String
>
cleaned
=
n
ew
LinkedHashSet
<>(
names
);
Set
<
String
>
cleaned
=
n
ames
.
stream
().
map
(
this
::
clean
).
collect
(
Collectors
.
toCollection
(
LinkedHashSet:
:
new
)
);
return
Collections
.
unmodifiableSet
(
cleaned
);
}
private
String
clean
(
String
name
)
{
return
name
.
trim
()
.
toLowerCase
()
;
return
name
.
trim
();
}
}
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/IncludeExcludeGroupMemberPredicateTests.java
View file @
a83852b7
...
...
@@ -68,6 +68,24 @@ class IncludeExcludeGroupMemberPredicateTests {
assertThat
(
predicate
).
rejects
(
"a"
,
"b"
,
"c"
,
"d"
);
}
@Test
void
testWhenCamelCaseIncludeAcceptsOnlyIncluded
()
{
Predicate
<
String
>
predicate
=
include
(
"myEndpoint"
).
exclude
();
assertThat
(
predicate
).
accepts
(
"myEndpoint"
).
rejects
(
"d"
);
}
@Test
void
testWhenHyphenCaseIncludeAcceptsOnlyIncluded
()
{
Predicate
<
String
>
predicate
=
include
(
"my-endpoint"
).
exclude
();
assertThat
(
predicate
).
accepts
(
"my-endpoint"
).
rejects
(
"d"
);
}
@Test
void
testWhenExtraWhitespaceAcceptsTrimmedVersion
()
{
Predicate
<
String
>
predicate
=
include
(
" myEndpoint "
).
exclude
();
assertThat
(
predicate
).
accepts
(
"myEndpoint"
).
rejects
(
"d"
);
}
private
Builder
include
(
String
...
include
)
{
return
new
Builder
(
include
);
}
...
...
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