diff --git a/docs/src/main/asciidoc/spring-cloud-commons.adoc b/docs/src/main/asciidoc/spring-cloud-commons.adoc index 58cc2808..080c2753 100644 --- a/docs/src/main/asciidoc/spring-cloud-commons.adoc +++ b/docs/src/main/asciidoc/spring-cloud-commons.adoc @@ -1375,7 +1375,7 @@ The per-client configuration properties work for most of the properties, apart f NOTE: For the properties where maps where already used, where you can specify a different value per-client without using the `clients` keyword (for example, `hints`, `health-check.path`), we have kept that behaviour in order to keep the library backwards compatible. It will be modified in the next major release. -NOTE: Starting with `4.0.4`, we have introduced the `callGetWithRequestOnDelegates` flag in `LoadBalancerProperties`. If this flag is set to `true`, `ServiceInstanceListSupplier#get(Request request)` method will be implemented to call `delegate.get(request)` in classes assignable from `DelegatingServiceInstanceListSupplier` that don't already implement that method, with the exclusion of `CachingServiceInstanceListSupplier` and `HealthCheckServiceInstanceListSupplier`, which should be placed in the instance supplier hierarchy directly after the supplier performing instance retrieval over the network, before any request-based filtering is done. For `4.0.x` the flag is set to `false` by default, however, since `4.1.0` it's going to be set to `true` by default. +NOTE: Starting with `4.1.0`, we have introduced the `callGetWithRequestOnDelegates` flag in `LoadBalancerProperties`. If this flag is set to `true`, `ServiceInstanceListSupplier#get(Request request)` method will be implemented to call `delegate.get(request)` in classes assignable from `DelegatingServiceInstanceListSupplier` that don't already implement that method, with the exclusion of `CachingServiceInstanceListSupplier` and `HealthCheckServiceInstanceListSupplier`, which should be placed in the instance supplier hierarchy directly after the supplier performing instance retrieval over the network, before any request-based filtering is done. It is set to `true` by default. === AOT and Native Image Support diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerProperties.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerProperties.java index 0e2c2121..dd93f89a 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerProperties.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/loadbalancer/LoadBalancerProperties.java @@ -80,10 +80,10 @@ public class LoadBalancerProperties { * method, with the exclusion of {@code CachingServiceInstanceListSupplier} and * {@code HealthCheckServiceInstanceListSupplier}, which should be placed in the * instance supplier hierarchy directly after the supplier performing instance - * retrieval over the network, before any request-based filtering is done. Note: in - * 4.1, this behaviour will become the default + * retrieval over the network, before any request-based filtering is done, + * {@code true} by default. */ - private boolean callGetWithRequestOnDelegates; + private boolean callGetWithRequestOnDelegates = true; public HealthCheck getHealthCheck() { return healthCheck; @@ -138,32 +138,10 @@ public class LoadBalancerProperties { return xForwarded; } - /** - * If this flag is set to {@code true}, - * {@code ServiceInstanceListSupplier#get(Request request)} method will be implemented - * to call {@code delegate.get(request)} in classes assignable from - * {@code DelegatingServiceInstanceListSupplier} that don't already implement that - * method, with the exclusion of {@code CachingServiceInstanceListSupplier} and - * {@code HealthCheckServiceInstanceListSupplier}, which should be placed in the - * instance supplier hierarchy directly after the supplier performing instance - * retrieval over the network, before any request-based filtering is done. Note: in - * 4.1, this behaviour will become the default - */ public boolean isCallGetWithRequestOnDelegates() { return callGetWithRequestOnDelegates; } - /** - * If this flag is set to {@code true}, - * {@code ServiceInstanceListSupplier#get(Request request)} method will be implemented - * to call {@code delegate.get(request)} in classes assignable from - * {@code DelegatingServiceInstanceListSupplier} that don't already implement that - * method, with the exclusion of {@code CachingServiceInstanceListSupplier} and - * {@code HealthCheckServiceInstanceListSupplier}, which should be placed in the - * instance supplier hierarchy directly after the supplier performing instance - * retrieval over the network, before any request-based filtering is done. Note: in - * 4.1, this behaviour will become the default - */ public void setCallGetWithRequestOnDelegates(boolean callGetWithRequestOnDelegates) { this.callGetWithRequestOnDelegates = callGetWithRequestOnDelegates; } diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/SameInstancePreferenceServiceInstanceListSupplierTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/SameInstancePreferenceServiceInstanceListSupplierTests.java index 81995b89..cb29c871 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/SameInstancePreferenceServiceInstanceListSupplierTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/SameInstancePreferenceServiceInstanceListSupplierTests.java @@ -62,7 +62,6 @@ class SameInstancePreferenceServiceInstanceListSupplierTests { @BeforeEach void setUp() { LoadBalancerProperties properties = new LoadBalancerProperties(); - properties.setCallGetWithRequestOnDelegates(true); when(loadBalancerClientFactory.getProperties(any())).thenReturn(properties); supplier = new SameInstancePreferenceServiceInstanceListSupplier(delegate, loadBalancerClientFactory); } diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/WeightedServiceInstanceListSupplierTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/WeightedServiceInstanceListSupplierTests.java index 58c00682..94c35020 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/WeightedServiceInstanceListSupplierTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/WeightedServiceInstanceListSupplierTests.java @@ -188,7 +188,6 @@ class WeightedServiceInstanceListSupplierTests { void shouldCallGetRequestOnDelegate() { LoadBalancerClientFactory loadBalancerClientFactory = mock(LoadBalancerClientFactory.class); LoadBalancerProperties properties = new LoadBalancerProperties(); - properties.setCallGetWithRequestOnDelegates(true); when(loadBalancerClientFactory.getProperties(any())).thenReturn(properties); ServiceInstance one = serviceInstance("test-1", Collections.emptyMap()); ServiceInstance two = serviceInstance("test-2", Collections.emptyMap()); diff --git a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ZonePreferenceServiceInstanceListSupplierTests.java b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ZonePreferenceServiceInstanceListSupplierTests.java index f04c9ba8..cea7bde2 100644 --- a/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ZonePreferenceServiceInstanceListSupplierTests.java +++ b/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/ZonePreferenceServiceInstanceListSupplierTests.java @@ -70,7 +70,6 @@ class ZonePreferenceServiceInstanceListSupplierTests { @BeforeEach void setUp() { LoadBalancerProperties properties = new LoadBalancerProperties(); - properties.setCallGetWithRequestOnDelegates(true); when(loadBalancerClientFactory.getProperties(any())).thenReturn(properties); supplier = new ZonePreferenceServiceInstanceListSupplier(delegate, zoneConfig, loadBalancerClientFactory); }