From bd2cc6f48bd89c1847a0ac44c8496f85c50b40e1 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 25 Mar 2019 11:30:45 +0100 Subject: [PATCH] Add missing condition on LogFile endpoint See gh-16298 --- .../logging/LogFileWebEndpointAutoConfiguration.java | 4 +++- .../logging/LogFileWebEndpointAutoConfigurationTests.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java index 9489a5bbf0..e9f4c19b54 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2019 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. @@ -16,6 +16,7 @@ package org.springframework.boot.actuate.autoconfigure.logging; +import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; import org.springframework.boot.actuate.logging.LogFileWebEndpoint; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionMessage; @@ -38,6 +39,7 @@ import org.springframework.util.StringUtils; * @since 2.0.0 */ @Configuration +@ConditionalOnEnabledEndpoint(endpoint = LogFileWebEndpoint.class) @EnableConfigurationProperties(LogFileWebEndpointProperties.class) public class LogFileWebEndpointAutoConfiguration { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java index aec1c9a27a..4182e5fffb 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 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. @@ -74,7 +74,7 @@ public class LogFileWebEndpointAutoConfigurationTests { .withPropertyValues("logging.file:test.log", "management.endpoint.logfile.enabled:false") .run((context) -> assertThat(context) - .hasSingleBean(LogFileWebEndpoint.class)); + .doesNotHaveBean(LogFileWebEndpoint.class)); } @Test