Browse Source

Adjust to changes in main.

pull/1243/head
Olga Maciaszek-Sharma 2 years ago
parent
commit
dbdb21a199
  1. 6
      spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/annotation/LoadBalancerClientConfiguration.java
  2. 14
      spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/annotation/LoadBalancerClientConfigurationTests.java

6
spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/annotation/LoadBalancerClientConfiguration.java

@ -139,7 +139,8 @@ public class LoadBalancerClientConfiguration { @@ -139,7 +139,8 @@ public class LoadBalancerClientConfiguration {
@ConditionalOnMissingBean
@Conditional(WeightedConfigurationCondition.class)
public ServiceInstanceListSupplier weightedServiceInstanceListSupplier(ConfigurableApplicationContext context) {
return ServiceInstanceListSupplier.builder().withDiscoveryClient().withWeighted().build(context);
return ServiceInstanceListSupplier.builder().withDiscoveryClient().withWeighted().withCaching()
.build(context);
}
}
@ -203,7 +204,8 @@ public class LoadBalancerClientConfiguration { @@ -203,7 +204,8 @@ public class LoadBalancerClientConfiguration {
@ConditionalOnMissingBean
@Conditional(WeightedConfigurationCondition.class)
public ServiceInstanceListSupplier weightedServiceInstanceListSupplier(ConfigurableApplicationContext context) {
return ServiceInstanceListSupplier.builder().withBlockingDiscoveryClient().withWeighted().build(context);
return ServiceInstanceListSupplier.builder().withBlockingDiscoveryClient().withWeighted().withCaching()
.build(context);
}
}

14
spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/annotation/LoadBalancerClientConfigurationTests.java

@ -120,10 +120,13 @@ class LoadBalancerClientConfigurationTests { @@ -120,10 +120,13 @@ class LoadBalancerClientConfigurationTests {
reactiveDiscoveryClientRunner.withUserConfiguration(TestConfig.class)
.withPropertyValues("spring.cloud.loadbalancer.configurations=weighted").run(context -> {
ServiceInstanceListSupplier supplier = context.getBean(ServiceInstanceListSupplier.class);
then(supplier).isInstanceOf(WeightedServiceInstanceListSupplier.class);
then(supplier).isInstanceOf(CachingServiceInstanceListSupplier.class);
ServiceInstanceListSupplier delegate = ((DelegatingServiceInstanceListSupplier) supplier)
.getDelegate();
then(delegate).isInstanceOf(DiscoveryClientServiceInstanceListSupplier.class);
then(delegate).isInstanceOf(WeightedServiceInstanceListSupplier.class);
ServiceInstanceListSupplier secondDelegate = ((DelegatingServiceInstanceListSupplier) delegate)
.getDelegate();
then(secondDelegate).isInstanceOf(DiscoveryClientServiceInstanceListSupplier.class);
});
}
@ -204,8 +207,11 @@ class LoadBalancerClientConfigurationTests { @@ -204,8 +207,11 @@ class LoadBalancerClientConfigurationTests {
blockingDiscoveryClientRunner.withUserConfiguration(RestTemplateTestConfig.class)
.withPropertyValues("spring.cloud.loadbalancer.configurations=weighted").run(context -> {
ServiceInstanceListSupplier supplier = context.getBean(ServiceInstanceListSupplier.class);
then(supplier).isInstanceOf(WeightedServiceInstanceListSupplier.class);
then(((DelegatingServiceInstanceListSupplier) supplier).getDelegate())
then(supplier).isInstanceOf(CachingServiceInstanceListSupplier.class);
ServiceInstanceListSupplier delegate = ((DelegatingServiceInstanceListSupplier) supplier)
.getDelegate();
then(delegate).isInstanceOf(WeightedServiceInstanceListSupplier.class);
then(((DelegatingServiceInstanceListSupplier) delegate).getDelegate())
.isInstanceOf(DiscoveryClientServiceInstanceListSupplier.class);
});
}

Loading…
Cancel
Save