Make JMX endpoints available when lazy init is enabled
Closes gh-28335
This commit is contained in:
parent
a722fe46fb
commit
a93cf64834
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2020 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.
|
||||
|
@ -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.expose.IncludeExcludeEndpointFilter;
|
||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||
|
@ -103,4 +104,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…
Reference in New Issue