Skip to content

Commit a4ba8f6

Browse files
committed
Backport 6dd8415
While working on gh-5309, a regression was introduced and fixed right the way on master. Unfortunately, the fix wasn't applied to `1.3.x` as it should have been. This commit applies 6dd8415 to `1.3.x` Closes gh-5901
1 parent 3891b24 commit a4ba8f6

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
@Configuration
4040
@ConditionalOnClass(EnableIntegration.class)
4141
@AutoConfigureAfter(JmxAutoConfiguration.class)
42-
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
4342
public class IntegrationAutoConfiguration {
4443

4544
@Configuration
@@ -50,6 +49,7 @@ protected static class IntegrationConfiguration {
5049
@Configuration
5150
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
5251
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
52+
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
5353
@EnableIntegrationMBeanExport(defaultDomain = "${spring.jmx.default-domain:}", server = "${spring.jmx.server:mbeanServer}")
5454
protected static class IntegrationJmxConfiguration {
5555
}

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.integration.support.channel.HeaderChannelRegistry;
3131
import org.springframework.test.context.support.TestPropertySourceUtils;
3232

33+
import static org.hamcrest.Matchers.hasSize;
3334
import static org.junit.Assert.assertEquals;
3435
import static org.junit.Assert.assertNotNull;
3536

@@ -94,6 +95,29 @@ public void parentContext() {
9495
this.context.close();
9596
}
9697

98+
@Test
99+
public void jmxIntegrationEnabledByDefault() {
100+
load();
101+
MBeanServer mBeanServer = this.context.getBean(MBeanServer.class);
102+
assertDomains(mBeanServer, true, "org.springframework.integration",
103+
"org.springframework.integration.monitor");
104+
}
105+
106+
@Test
107+
public void disableJmxIntegration() {
108+
load("spring.jmx.enabled=false");
109+
assertEquals(this.context.getBeansOfType(MBeanServer.class), hasSize(0));
110+
}
111+
112+
@Test
113+
public void customizeJmxDomain() {
114+
load("spring.jmx.default-domain=org.foo");
115+
MBeanServer mBeanServer = this.context.getBean(MBeanServer.class);
116+
assertDomains(mBeanServer, true, "org.foo");
117+
assertDomains(mBeanServer, false, "org.springframework.integration",
118+
"org.springframework.integration.monitor");
119+
}
120+
97121
private static void assertDomains(MBeanServer mBeanServer, boolean expected,
98122
String... domains) {
99123
List<String> actual = Arrays.asList(mBeanServer.getDomains());

0 commit comments

Comments
 (0)