Merge branch '2.5.x'

Closes gh-28372
pull/28376/head
Andy Wilkinson 3 years ago
commit 42ef97b9ec

@ -23,6 +23,7 @@ import javax.management.MBeanServer;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.LazyInitializationExcludeFilter;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.IncludeExcludeEndpointFilter;
import org.springframework.boot.actuate.endpoint.EndpointFilter;
@ -110,4 +111,9 @@ public class JmxEndpointAutoConfiguration {
exposure.getExclude(), "*");
}
@Bean
static LazyInitializationExcludeFilter eagerlyInitializeJmxEndpointExporter() {
return LazyInitializationExcludeFilter.forBeanTypes(JmxEndpointExporter.class);
}
}

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,6 +26,7 @@ import javax.management.ReflectionException;
import org.junit.jupiter.api.Test;
import org.springframework.boot.LazyInitializationBeanFactoryPostProcessor;
import org.springframework.boot.actuate.audit.InMemoryAuditEventRepository;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.jmx.JmxEndpointAutoConfiguration;
@ -66,6 +67,16 @@ class JmxEndpointIntegrationTests {
});
}
@Test
void jmxEndpointsAreExposedWhenLazyInitializationIsEnabled() {
this.contextRunner.withBean(LazyInitializationBeanFactoryPostProcessor.class,
LazyInitializationBeanFactoryPostProcessor::new).run((context) -> {
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, new String[] { "beans", "conditions", "configprops", "env",
"health", "info", "mappings", "threaddump", "httptrace" }, new String[] { "shutdown" });
});
}
@Test
void jmxEndpointsCanBeExcluded() {
this.contextRunner.withPropertyValues("management.endpoints.jmx.exposure.exclude:*").run((context) -> {

Loading…
Cancel
Save