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
19b7dc8e
Commit
19b7dc8e
authored
Feb 11, 2020
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x'
Closes gh-20114
parents
ec42dcd1
d485708f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
HealthEndpointSupport.java
...gframework/boot/actuate/health/HealthEndpointSupport.java
+8
-7
HealthEndpointSupportTests.java
...ework/boot/actuate/health/HealthEndpointSupportTests.java
+16
-1
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpointSupport.java
View file @
19b7dc8e
...
@@ -72,7 +72,7 @@ abstract class HealthEndpointSupport<C, T> {
...
@@ -72,7 +72,7 @@ abstract class HealthEndpointSupport<C, T> {
}
}
Object
contributor
=
getContributor
(
path
,
pathOffset
);
Object
contributor
=
getContributor
(
path
,
pathOffset
);
T
health
=
getContribution
(
apiVersion
,
group
,
contributor
,
showComponents
,
showDetails
,
T
health
=
getContribution
(
apiVersion
,
group
,
contributor
,
showComponents
,
showDetails
,
isSystemHealth
?
this
.
groups
.
getNames
()
:
null
);
isSystemHealth
?
this
.
groups
.
getNames
()
:
null
,
false
);
return
(
health
!=
null
)
?
new
HealthResult
<>(
health
,
group
)
:
null
;
return
(
health
!=
null
)
?
new
HealthResult
<>(
health
,
group
)
:
null
;
}
}
...
@@ -91,23 +91,24 @@ abstract class HealthEndpointSupport<C, T> {
...
@@ -91,23 +91,24 @@ abstract class HealthEndpointSupport<C, T> {
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
T
getContribution
(
ApiVersion
apiVersion
,
HealthEndpointGroup
group
,
Object
contributor
,
private
T
getContribution
(
ApiVersion
apiVersion
,
HealthEndpointGroup
group
,
Object
contributor
,
boolean
showComponents
,
boolean
showDetails
,
Set
<
String
>
groupNames
)
{
boolean
showComponents
,
boolean
showDetails
,
Set
<
String
>
groupNames
,
boolean
isNested
)
{
if
(
contributor
instanceof
NamedContributors
)
{
if
(
contributor
instanceof
NamedContributors
)
{
return
getAggregateHealth
(
apiVersion
,
group
,
(
NamedContributors
<
C
>)
contributor
,
showComponents
,
return
getAggregateHealth
(
apiVersion
,
group
,
(
NamedContributors
<
C
>)
contributor
,
showComponents
,
showDetails
,
groupNames
);
showDetails
,
groupNames
,
isNested
);
}
}
return
(
contributor
!=
null
)
?
getHealth
((
C
)
contributor
,
showDetails
)
:
null
;
return
(
contributor
!=
null
)
?
getHealth
((
C
)
contributor
,
showDetails
)
:
null
;
}
}
private
T
getAggregateHealth
(
ApiVersion
apiVersion
,
HealthEndpointGroup
group
,
private
T
getAggregateHealth
(
ApiVersion
apiVersion
,
HealthEndpointGroup
group
,
NamedContributors
<
C
>
namedContributors
,
boolean
showComponents
,
boolean
showDetails
,
NamedContributors
<
C
>
namedContributors
,
boolean
showComponents
,
boolean
showDetails
,
Set
<
String
>
groupNames
,
Set
<
String
>
groupNames
)
{
boolean
isNested
)
{
Map
<
String
,
T
>
contributions
=
new
LinkedHashMap
<>();
Map
<
String
,
T
>
contributions
=
new
LinkedHashMap
<>();
for
(
NamedContributor
<
C
>
namedContributor
:
namedContributors
)
{
for
(
NamedContributor
<
C
>
namedContributor
:
namedContributors
)
{
String
name
=
namedContributor
.
getName
();
String
name
=
namedContributor
.
getName
();
C
contributor
=
namedContributor
.
getContributor
();
C
contributor
=
namedContributor
.
getContributor
();
if
(
group
.
isMember
(
name
))
{
if
(
group
.
isMember
(
name
)
||
isNested
)
{
T
contribution
=
getContribution
(
apiVersion
,
group
,
contributor
,
showComponents
,
showDetails
,
null
);
T
contribution
=
getContribution
(
apiVersion
,
group
,
contributor
,
showComponents
,
showDetails
,
null
,
true
);
if
(
contribution
!=
null
)
{
if
(
contribution
!=
null
)
{
contributions
.
put
(
name
,
contribution
);
contributions
.
put
(
name
,
contribution
);
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointSupportTests.java
View file @
19b7dc8e
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
...
@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @param <C> the contributor type
* @param <C> the contributor type
* @param <T> the contributed health component type
* @param <T> the contributed health component type
* @author Phillip Webb
* @author Phillip Webb
* @author Madhura Bhave
*/
*/
abstract
class
HealthEndpointSupportTests
<
R
extends
ContributorRegistry
<
C
>,
C
,
T
>
{
abstract
class
HealthEndpointSupportTests
<
R
extends
ContributorRegistry
<
C
>,
C
,
T
>
{
...
@@ -215,6 +216,20 @@ abstract class HealthEndpointSupportTests<R extends ContributorRegistry<C>, C, T
...
@@ -215,6 +216,20 @@ abstract class HealthEndpointSupportTests<R extends ContributorRegistry<C>, C, T
assertThat
(
result
).
isNull
();
assertThat
(
result
).
isNull
();
}
}
@Test
void
getHealthWhenGroupContainsCompositeContributorReturnsHealth
()
{
C
contributor
=
createContributor
(
this
.
up
);
C
compositeContributor
=
createCompositeContributor
(
Collections
.
singletonMap
(
"spring"
,
contributor
));
this
.
registry
.
registerContributor
(
"test"
,
compositeContributor
);
TestHealthEndpointGroup
testGroup
=
new
TestHealthEndpointGroup
((
name
)
->
name
.
startsWith
(
"test"
));
HealthEndpointGroups
groups
=
HealthEndpointGroups
.
of
(
this
.
primaryGroup
,
Collections
.
singletonMap
(
"testGroup"
,
testGroup
));
HealthResult
<
T
>
result
=
create
(
this
.
registry
,
groups
).
getHealth
(
ApiVersion
.
V3
,
SecurityContext
.
NONE
,
false
,
"testGroup"
);
CompositeHealth
health
=
(
CompositeHealth
)
getHealth
(
result
);
assertThat
(
health
.
getComponents
()).
containsKey
(
"test"
);
}
protected
abstract
HealthEndpointSupport
<
C
,
T
>
create
(
R
registry
,
HealthEndpointGroups
groups
);
protected
abstract
HealthEndpointSupport
<
C
,
T
>
create
(
R
registry
,
HealthEndpointGroups
groups
);
protected
abstract
R
createRegistry
();
protected
abstract
R
createRegistry
();
...
...
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