Disable Jolokia by default

To be consistent with Actuator web endpoints, Jolokia is now disabled
by default.

Closes gh-10090
pull/10101/head
Stephane Nicoll 7 years ago
parent def094b844
commit da65158eae

@ -54,7 +54,7 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
@ManagementContextConfiguration
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
@ConditionalOnProperty(value = "management.jolokia.enabled", matchIfMissing = true)
@ConditionalOnProperty(value = "management.jolokia.enabled", havingValue = "true")
@EnableConfigurationProperties(JolokiaProperties.class)
public class JolokiaManagementContextConfiguration {

@ -35,7 +35,7 @@ public class JolokiaProperties {
/**
* Enable Jolokia.
*/
private boolean enabled = true;
private boolean enabled;
/**
* Path at which Jolokia will be available.

@ -58,7 +58,8 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext
@TestPropertySource(properties = "management.security.enabled=false")
@TestPropertySource(properties = { "management.jolokia.enabled=true",
"management.security.enabled=false" })
public class JolokiaManagementContextConfigurationIntegrationTests {
@Autowired

@ -44,45 +44,47 @@ public class JolokiaManagementContextConfigurationTests {
@Test
public void jolokiaIsEnabledByDefault() {
this.contextRunner.run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class);
assertThat(registrationBean.getUrlMappings())
.contains("/application/jolokia/*");
assertThat(registrationBean.getInitParameters()).isEmpty();
});
this.contextRunner.withPropertyValues("management.jolokia.enabled=true")
.run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class);
assertThat(registrationBean.getUrlMappings())
.contains("/application/jolokia/*");
assertThat(registrationBean.getInitParameters()).isEmpty();
});
}
@Test
public void jolokiaCanBeDisabled() {
this.contextRunner.withPropertyValues("management.jolokia.enabled=false")
.run((context) -> assertThat(context)
.doesNotHaveBean(ServletRegistrationBean.class));
public void jolokiaIsDisabledByDefault() {
this.contextRunner.run((context) -> assertThat(context)
.doesNotHaveBean(ServletRegistrationBean.class));
}
@Test
public void customPath() {
this.contextRunner.withPropertyValues("management.jolokia.path=/lokia")
.run(isDefinedOnPath("/application/lokia/*"));
this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
"management.jolokia.path=/lokia").run(
isDefinedOnPath("/application/lokia/*"));
}
@Test
public void customManagementPath() {
this.contextRunner.withPropertyValues("management.context-path=/admin")
.run(isDefinedOnPath("/admin/jolokia/*"));
this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
"management.context-path=/admin").run(
isDefinedOnPath("/admin/jolokia/*"));
}
@Test
public void customInitParameters() {
this.contextRunner.withPropertyValues("management.jolokia.config.debug=true")
.run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class);
assertThat(registrationBean.getInitParameters())
.containsOnly(entry("debug", "true"));
});
this.contextRunner.withPropertyValues("management.jolokia.enabled=true",
"management.jolokia.config.debug=true").run((context) -> {
assertThat(context).hasSingleBean(ServletRegistrationBean.class);
ServletRegistrationBean<?> registrationBean = context
.getBean(ServletRegistrationBean.class);
assertThat(registrationBean.getInitParameters())
.containsOnly(entry("debug", "true"));
});
}
private ContextConsumer<AssertableWebApplicationContext> isDefinedOnPath(

@ -1274,7 +1274,7 @@ content into your application; rather pick only the properties that you need.
# JOLOKIA ({sc-spring-boot-actuator}/autoconfigure/jolokia/JolokiaProperties.{sc-ext}[JolokiaProperties])
management.jolokia.config.*= # Jolokia settings. See the Jolokia manual for details.
management.jolokia.enabled=true # Enable Jolokia.
management.jolokia.enabled=false # Enable Jolokia.
management.jolokia.path=/jolokia # Path at which Jolokia will be available.
# TRACING ({sc-spring-boot-actuator}/trace/TraceProperties.{sc-ext}[TraceProperties])

@ -1,2 +1,3 @@
health.diskspace.enabled=false
endpoints.all.web.enabled=true
endpoints.all.web.enabled=true
management.jolokia.enabled=true
Loading…
Cancel
Save