Browse Source

Merge remote-tracking branch 'origin/main' into aot-support

aot-support
Olga Maciaszek-Sharma 2 years ago
parent
commit
ec64c62abb
  1. 3
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java
  2. 9
      spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java

3
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsConfiguration.java

@ -238,19 +238,18 @@ public class FeignClientsConfiguration { @@ -238,19 +238,18 @@ public class FeignClientsConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(name = "spring.cloud.openfeign.micrometer.enabled", matchIfMissing = true)
@ConditionalOnClass({ MicrometerObservationCapability.class, MicrometerCapability.class, MeterRegistry.class })
@Conditional(FeignClientMicrometerEnabledCondition.class)
protected static class MicrometerConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(name = "feign.micrometer.MicrometerObservationCapability")
@ConditionalOnBean(type = "io.micrometer.observation.ObservationRegistry")
public MicrometerObservationCapability micrometerObservationCapability(ObservationRegistry registry) {
return new MicrometerObservationCapability(registry);
}
@Bean
@ConditionalOnClass(name = "feign.micrometer.MicrometerCapability")
@ConditionalOnBean(type = "io.micrometer.core.instrument.MeterRegistry")
@ConditionalOnMissingBean({ MicrometerCapability.class, MicrometerObservationCapability.class })
public MicrometerCapability micrometerCapability(MeterRegistry registry) {

9
spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientsMicrometerAutoConfigurationTests.java

@ -63,15 +63,14 @@ class FeignClientsMicrometerAutoConfigurationTests { @@ -63,15 +63,14 @@ class FeignClientsMicrometerAutoConfigurationTests {
}
@Test
void shouldProvideMicrometerCapabilityIfMicrometerObservationCapabilityIsNotOnClasspath() {
contextRunner.withClassLoader(new FilteredClassLoader(MicrometerObservationCapability.class))
.run(context -> assertThat(context).doesNotHaveBean(MicrometerObservationCapability.class)
.hasSingleBean(MicrometerCapability.class));
void shouldNotProvideMicrometerCapabilitiesIfFeignMicrometerSupportIsMissing() {
contextRunner.withClassLoader(new FilteredClassLoader("feign.micrometer")).run(context -> assertThat(context)
.doesNotHaveBean(MicrometerObservationCapability.class).doesNotHaveBean(MicrometerCapability.class));
}
@Test
void shouldNotProvideMicrometerCapabilitiesIfMicrometerSupportIsMissing() {
contextRunner.withClassLoader(new FilteredClassLoader("feign.micrometer")).run(context -> assertThat(context)
contextRunner.withClassLoader(new FilteredClassLoader("io.micrometer")).run(context -> assertThat(context)
.doesNotHaveBean(MicrometerObservationCapability.class).doesNotHaveBean(MicrometerCapability.class));
}

Loading…
Cancel
Save