mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-28 21:19:02 +00:00
Avoid loading health classes in Cloud Foundry
Move the Cloud Foundry health endpoint extension bean into a health-specific configuration. This lets the actuator configuration refresh when spring-boot-health is absent. See gh-50857 Signed-off-by: Lee JiWon <dlwldnjs1009@gmail.com>
This commit is contained in:
committed by
Andy Wilkinson
parent
4c5aee76c7
commit
48054ea77b
+15
-9
@@ -87,15 +87,6 @@ public final class CloudFoundryActuatorAutoConfiguration {
|
||||
|
||||
private static final String BASE_PATH = "/cloudfoundryapplication";
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnAvailableEndpoint
|
||||
@ConditionalOnBean({ HealthEndpoint.class, HealthEndpointWebExtension.class })
|
||||
CloudFoundryHealthEndpointWebExtension cloudFoundryHealthEndpointWebExtension(
|
||||
HealthEndpointWebExtension healthEndpointWebExtension) {
|
||||
return new CloudFoundryHealthEndpointWebExtension(healthEndpointWebExtension);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnAvailableEndpoint
|
||||
@@ -157,6 +148,21 @@ public final class CloudFoundryActuatorAutoConfiguration {
|
||||
return corsConfiguration;
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(HealthEndpoint.class)
|
||||
static class HealthConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnAvailableEndpoint
|
||||
@ConditionalOnBean({ HealthEndpoint.class, HealthEndpointWebExtension.class })
|
||||
CloudFoundryHealthEndpointWebExtension cloudFoundryHealthEndpointWebExtension(
|
||||
HealthEndpointWebExtension healthEndpointWebExtension) {
|
||||
return new CloudFoundryHealthEndpointWebExtension(healthEndpointWebExtension);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link WebSecurityConfigurer} to tell Spring Security to permit cloudfoundry
|
||||
* specific paths. The Cloud foundry endpoints are protected by their own security
|
||||
|
||||
+10
@@ -47,6 +47,7 @@ import org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSec
|
||||
import org.springframework.boot.servlet.autoconfigure.actuate.web.ServletManagementContextAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration;
|
||||
import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -92,6 +93,15 @@ class CloudFoundryActuatorAutoConfigurationTests {
|
||||
ServletManagementContextAutoConfiguration.class, EndpointAutoConfiguration.class,
|
||||
WebEndpointAutoConfiguration.class, CloudFoundryActuatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
@ClassPathExclusions(packages = "org.springframework.boot.health.actuate.endpoint")
|
||||
void refreshSucceedsWithoutHealth() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id",
|
||||
"vcap.application.cf_api:https://my-cloud-controller.com")
|
||||
.run((context) -> assertThat(context).hasNotFailed());
|
||||
}
|
||||
|
||||
@Test
|
||||
void cloudFoundryPlatformActive() {
|
||||
this.contextRunner
|
||||
|
||||
Reference in New Issue
Block a user