Skip to content

Commit 42ef97b

Browse files
committed
Merge branch '2.5.x'
Closes gh-28372
2 parents 416a3d6 + 5f4c001 commit 42ef97b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.fasterxml.jackson.databind.ObjectMapper;
2424

2525
import org.springframework.beans.factory.ObjectProvider;
26+
import org.springframework.boot.LazyInitializationExcludeFilter;
2627
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
2728
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.IncludeExcludeEndpointFilter;
2829
import org.springframework.boot.actuate.endpoint.EndpointFilter;
@@ -110,4 +111,9 @@ public IncludeExcludeEndpointFilter<ExposableJmxEndpoint> jmxIncludeExcludePrope
110111
exposure.getExclude(), "*");
111112
}
112113

114+
@Bean
115+
static LazyInitializationExcludeFilter eagerlyInitializeJmxEndpointExporter() {
116+
return LazyInitializationExcludeFilter.forBeanTypes(JmxEndpointExporter.class);
117+
}
118+
113119
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JmxEndpointIntegrationTests.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626

2727
import org.junit.jupiter.api.Test;
2828

29+
import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
2930
import org.springframework.boot.actuate.audit.InMemoryAuditEventRepository;
3031
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
3132
import org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration;
@@ -66,6 +67,16 @@ void jmxEndpointsAreExposed() {
6667
});
6768
}
6869

70+
@Test
71+
void jmxEndpointsAreExposedWhenLazyInitializationIsEnabled() {
72+
this.contextRunner.withBean(LazyInitializationBeanFactoryPostProcessor.class,
73+
LazyInitializationBeanFactoryPostProcessor::new).run((context) -> {
74+
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
75+
checkEndpointMBeans(mBeanServer, new String[] { "beans", "conditions", "configprops", "env",
76+
"health", "info", "mappings", "threaddump", "httptrace" }, new String[] { "shutdown" });
77+
});
78+
}
79+
6980
@Test
7081
void jmxEndpointsCanBeExcluded() {
7182
this.contextRunner.withPropertyValues("management.endpoints.jmx.exposure.exclude:*").run((context) -> {

0 commit comments

Comments
 (0)