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
12a16dcf
Commit
12a16dcf
authored
Nov 15, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
578f093d
5183dd12
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
EndpointDiscoverer.java
.../boot/actuate/endpoint/annotation/EndpointDiscoverer.java
+10
-6
EndpointDiscovererTests.java
.../actuate/endpoint/annotation/EndpointDiscovererTests.java
+27
-0
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java
View file @
12a16dcf
...
@@ -30,6 +30,7 @@ import java.util.function.Function;
...
@@ -30,6 +30,7 @@ import java.util.function.Function;
import
java.util.function.Supplier
;
import
java.util.function.Supplier
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.springframework.aop.scope.ScopedProxyUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.BeanFactoryUtils
;
import
org.springframework.beans.factory.BeanFactoryUtils
;
import
org.springframework.boot.actuate.endpoint.EndpointFilter
;
import
org.springframework.boot.actuate.endpoint.EndpointFilter
;
...
@@ -131,12 +132,15 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
...
@@ -131,12 +132,15 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
String
[]
beanNames
=
BeanFactoryUtils
.
beanNamesForAnnotationIncludingAncestors
(
String
[]
beanNames
=
BeanFactoryUtils
.
beanNamesForAnnotationIncludingAncestors
(
this
.
applicationContext
,
Endpoint
.
class
);
this
.
applicationContext
,
Endpoint
.
class
);
for
(
String
beanName
:
beanNames
)
{
for
(
String
beanName
:
beanNames
)
{
EndpointBean
endpointBean
=
createEndpointBean
(
beanName
);
if
(!
ScopedProxyUtils
.
isScopedTarget
(
beanName
))
{
EndpointBean
previous
=
byId
.
putIfAbsent
(
endpointBean
.
getId
(),
endpointBean
);
EndpointBean
endpointBean
=
createEndpointBean
(
beanName
);
Assert
.
state
(
previous
==
null
,
EndpointBean
previous
=
byId
.
putIfAbsent
(
endpointBean
.
getId
(),
()
->
"Found two endpoints with the id '"
+
endpointBean
.
getId
()
endpointBean
);
+
"': '"
+
endpointBean
.
getBeanName
()
+
"' and '"
Assert
.
state
(
previous
==
null
,
+
previous
.
getBeanName
()
+
"'"
);
()
->
"Found two endpoints with the id '"
+
endpointBean
.
getId
()
+
"': '"
+
endpointBean
.
getBeanName
()
+
"' and '"
+
previous
.
getBeanName
()
+
"'"
);
}
}
}
return
byId
.
values
();
return
byId
.
values
();
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java
View file @
12a16dcf
...
@@ -148,6 +148,18 @@ public class EndpointDiscovererTests {
...
@@ -148,6 +148,18 @@ public class EndpointDiscovererTests {
"Found two endpoints with the id 'test': "
));
"Found two endpoints with the id 'test': "
));
}
}
@Test
public
void
getEndpointsWhenEndpointsArePrefixedWithScopedTargetShouldRegisterOnlyOneEndpoint
()
{
load
(
ScopedTargetEndpointConfiguration
.
class
,
(
context
)
->
{
TestEndpoint
expectedEndpoint
=
context
.
getBean
(
ScopedTargetEndpointConfiguration
.
class
).
testEndpoint
();
Collection
<
TestExposableEndpoint
>
endpoints
=
new
TestEndpointDiscoverer
(
context
).
getEndpoints
();
assertThat
(
endpoints
).
flatExtracting
(
TestExposableEndpoint:
:
getEndpointBean
)
.
containsOnly
(
expectedEndpoint
);
});
}
@Test
@Test
public
void
getEndpointsWhenTtlSetToZeroShouldNotCacheInvokeCalls
()
{
public
void
getEndpointsWhenTtlSetToZeroShouldNotCacheInvokeCalls
()
{
load
(
TestEndpointConfiguration
.
class
,
(
context
)
->
{
load
(
TestEndpointConfiguration
.
class
,
(
context
)
->
{
...
@@ -393,6 +405,21 @@ public class EndpointDiscovererTests {
...
@@ -393,6 +405,21 @@ public class EndpointDiscovererTests {
}
}
@Configuration
static
class
ScopedTargetEndpointConfiguration
{
@Bean
public
TestEndpoint
testEndpoint
()
{
return
new
TestEndpoint
();
}
@Bean
(
name
=
"scopedTarget.testEndpoint"
)
public
TestEndpoint
scopedTargetTestEndpoint
()
{
return
new
TestEndpoint
();
}
}
@Import
({
TestEndpoint
.
class
,
SpecializedTestEndpoint
.
class
,
@Import
({
TestEndpoint
.
class
,
SpecializedTestEndpoint
.
class
,
SpecializedExtension
.
class
})
SpecializedExtension
.
class
})
static
class
SpecializedEndpointsConfiguration
{
static
class
SpecializedEndpointsConfiguration
{
...
...
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