Skip to content

Commit

Permalink
Merge branch '2.4.x' into 2.5.x
Browse files Browse the repository at this point in the history
Closes gh-28371
  • Loading branch information
wilkinsona committed Oct 18, 2021
2 parents e865c3a + a93cf64 commit 5f4c001
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -110,4 +111,9 @@ public IncludeExcludeEndpointFilter<ExposableJmxEndpoint> jmxIncludeExcludePrope
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.
Expand All @@ -26,6 +26,7 @@

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;
Expand Down Expand Up @@ -66,6 +67,16 @@ void jmxEndpointsAreExposed() {
});
}

@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) -> {
Expand Down

0 comments on commit 5f4c001

Please sign in to comment.