Polish "Polish SpringApplicationAdminJmxAutoConfigurationTests"
See gh-26416
This commit is contained in:
parent
b263f126fa
commit
0e2bb5f179
|
|
@ -36,13 +36,13 @@ import org.springframework.jmx.export.MBeanExporter;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Andy Wilkinson
|
||||
* @author Nguyen Bao Sach
|
||||
* @since 1.3.0
|
||||
* @see SpringApplicationAdminMXBean
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AutoConfigureAfter(JmxAutoConfiguration.class)
|
||||
@ConditionalOnProperty(prefix = "spring.application.admin", value = "enabled", havingValue = "true")
|
||||
@ConditionalOnProperty(prefix = "spring.application.admin", value = "enabled", havingValue = "true",
|
||||
matchIfMissing = false)
|
||||
public class SpringApplicationAdminJmxAutoConfiguration {
|
||||
|
||||
/**
|
||||
|
|
@ -61,8 +61,11 @@ public class SpringApplicationAdminJmxAutoConfiguration {
|
|||
public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar(
|
||||
ObjectProvider<MBeanExporter> mbeanExporters, Environment environment) throws MalformedObjectNameException {
|
||||
String jmxName = environment.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);
|
||||
// Make sure to not register that MBean twice
|
||||
mbeanExporters.forEach((mbeanExporter) -> mbeanExporter.addExcludedBean(jmxName));
|
||||
if (mbeanExporters != null) { // Make sure to not register that MBean twice
|
||||
for (MBeanExporter mbeanExporter : mbeanExporters) {
|
||||
mbeanExporter.addExcludedBean(jmxName);
|
||||
}
|
||||
}
|
||||
return new SpringApplicationAdminMXBeanRegistrar(jmxName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -64,7 +64,7 @@ class SpringApplicationAdminJmxAutoConfigurationTests {
|
|||
.withConfiguration(AutoConfigurations.of(SpringApplicationAdminJmxAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
void WhenThereAreNotAnyMBeanExporters() {
|
||||
void notRegisteredWhenThereAreNoMBeanExporter() {
|
||||
this.contextRunner.withPropertyValues(ENABLE_ADMIN_PROP).run((context) -> {
|
||||
ObjectName objectName = createDefaultObjectName();
|
||||
ObjectInstance objectInstance = this.server.getObjectInstance(objectName);
|
||||
|
|
|
|||
Loading…
Reference in New Issue