Browse Source

Ensure `JmxEndpoint` beans get context object IDs

Update `EndpointMBeanExporter` to ensure that `JmxEndpoint` as well
as regular `Endpoint` beans are considered when searching the parent
context.

Prior to this commit if the same `JmxEndpoint` was registered in the
both the child and parent context then the `context=` element of the
name wasn't added.

Fixes gh-8152
pull/8206/head
Phillip Webb 9 years ago
parent
commit
21234b36de
  1. 10
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java

10
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java

@ -283,13 +283,15 @@ public class EndpointMBeanExporter extends MBeanExporter
String beanKey) { String beanKey) {
if (applicationContext.getParent() != null) { if (applicationContext.getParent() != null) {
try { try {
this.applicationContext.getParent().getBean(beanKey, Endpoint.class); Object bean = this.applicationContext.getParent().getBean(beanKey);
return true; if (bean instanceof Endpoint || bean instanceof JmxEndpoint) {
return true;
}
} }
catch (BeansException ex) { catch (BeansException ex) {
return parentContextContainsSameBean(applicationContext.getParent(), // Ignore and continue
beanKey);
} }
return parentContextContainsSameBean(applicationContext.getParent(), beanKey);
} }
return false; return false;
} }

Loading…
Cancel
Save