Browse Source

Remove deprecated method use.

pull/1278/head
Olga MaciaszekSharma 1 year ago
parent
commit
12e709cdc6
  1. 16
      spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilder.java
  2. 2
      spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSuppliersTestUtils.java

16
spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSupplierBuilder.java

@ -145,7 +145,7 @@ public final class ServiceInstanceListSupplierBuilder { @@ -145,7 +145,7 @@ public final class ServiceInstanceListSupplierBuilder {
public ServiceInstanceListSupplierBuilder withHealthChecks() {
DelegateCreator creator = (context, delegate) -> {
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerClientFactory = context
.getBean(LoadBalancerClientFactory.class);
.getBean(LoadBalancerClientFactory.class);
WebClient.Builder webClient = context.getBean(WebClient.Builder.class);
return healthCheckServiceInstanceListSupplier(webClient.build(), delegate, loadBalancerClientFactory);
};
@ -268,7 +268,7 @@ public final class ServiceInstanceListSupplierBuilder { @@ -268,7 +268,7 @@ public final class ServiceInstanceListSupplierBuilder {
}
this.cachingCreator = (context, delegate) -> {
ObjectProvider<LoadBalancerCacheManager> cacheManagerProvider = context
.getBeanProvider(LoadBalancerCacheManager.class);
.getBeanProvider(LoadBalancerCacheManager.class);
if (cacheManagerProvider.getIfAvailable() != null) {
return new CachingServiceInstanceListSupplier(delegate, cacheManagerProvider.getIfAvailable());
}
@ -334,10 +334,9 @@ public final class ServiceInstanceListSupplierBuilder { @@ -334,10 +334,9 @@ public final class ServiceInstanceListSupplierBuilder {
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerClientFactory) {
return new HealthCheckServiceInstanceListSupplier(delegate, loadBalancerClientFactory,
(serviceInstance, healthCheckPath) -> webClient.get()
.uri(UriComponentsBuilder.fromUriString(getUri(serviceInstance, healthCheckPath)).build()
.toUri())
.uri(UriComponentsBuilder.fromUriString(getUri(serviceInstance, healthCheckPath)).build().toUri())
.exchange().flatMap(clientResponse -> clientResponse.releaseBody()
.thenReturn(HttpStatus.OK.value() == clientResponse.rawStatusCode())));
.thenReturn(HttpStatus.OK.equals(clientResponse.statusCode()))));
}
private ServiceInstanceListSupplier blockingHealthCheckServiceInstanceListSupplier(RestTemplate restTemplate,
@ -345,11 +344,12 @@ public final class ServiceInstanceListSupplierBuilder { @@ -345,11 +344,12 @@ public final class ServiceInstanceListSupplierBuilder {
ReactiveLoadBalancer.Factory<ServiceInstance> loadBalancerClientFactory) {
return new HealthCheckServiceInstanceListSupplier(delegate, loadBalancerClientFactory,
(serviceInstance, healthCheckPath) -> Mono.defer(() -> {
URI uri = UriComponentsBuilder.fromUriString(getUri(serviceInstance, healthCheckPath)).build()
.toUri();
URI uri = UriComponentsBuilder.fromUriString(getUri(serviceInstance, healthCheckPath))
.build()
.toUri();
try {
return Mono
.just(HttpStatus.OK.equals(restTemplate.getForEntity(uri, Void.class).getStatusCode()));
.just(HttpStatus.OK.equals(restTemplate.getForEntity(uri, Void.class).getStatusCode()));
}
catch (Exception ignored) {
return Mono.just(false);

2
spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSuppliersTestUtils.java

@ -46,7 +46,7 @@ final class ServiceInstanceListSuppliersTestUtils { @@ -46,7 +46,7 @@ final class ServiceInstanceListSuppliersTestUtils {
return (serviceInstance, healthCheckPath) -> webClient.get()
.uri(UriComponentsBuilder.fromUriString(getUri(serviceInstance, healthCheckPath)).build().toUri())
.exchange().flatMap(clientResponse -> clientResponse.releaseBody()
.thenReturn(HttpStatus.OK.value() == clientResponse.rawStatusCode()));
.thenReturn(HttpStatus.OK.equals(clientResponse.statusCode())));
}
static BiFunction<ServiceInstance, String, Mono<Boolean>> healthCheckFunction(RestTemplate restTemplate) {

Loading…
Cancel
Save