Browse Source

Add public delegate modifiers in order to avoid reflection in SC Sleuth.

pull/258/head
Olga Maciaszek-Sharma 5 years ago
parent
commit
05b58e087e
  1. 16
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/loadbalancer/FeignBlockingLoadBalancerClient.java
  2. 7
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java

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

@ -41,14 +41,14 @@ import org.springframework.util.Assert; @@ -41,14 +41,14 @@ import org.springframework.util.Assert;
public class FeignBlockingLoadBalancerClient implements Client {
private static final Log LOG = LogFactory
.getLog(FeignBlockingLoadBalancerClient.class);
private final Client delegate;
.getLog(FeignBlockingLoadBalancerClient.class);
private final BlockingLoadBalancerClient loadBalancerClient;
private Client delegate;
public FeignBlockingLoadBalancerClient(Client delegate,
BlockingLoadBalancerClient loadBalancerClient) {
BlockingLoadBalancerClient loadBalancerClient) {
this.delegate = delegate;
this.loadBalancerClient = loadBalancerClient;
}
@ -58,7 +58,7 @@ public class FeignBlockingLoadBalancerClient implements Client { @@ -58,7 +58,7 @@ public class FeignBlockingLoadBalancerClient implements Client {
final URI originalUri = URI.create(request.url());
String serviceId = originalUri.getHost();
Assert.state(serviceId != null,
"Request URI does not contain a valid hostname: " + originalUri);
"Request URI does not contain a valid hostname: " + originalUri);
ServiceInstance instance = loadBalancerClient.choose(serviceId);
if (instance == null) {
String message = "Load balancer does not contain an instance for the service "
@ -78,8 +78,14 @@ public class FeignBlockingLoadBalancerClient implements Client { @@ -78,8 +78,14 @@ public class FeignBlockingLoadBalancerClient implements Client {
return delegate.execute(newRequest, options);
}
// Visible for Sleuth instrumentation
public Client getDelegate() {
return delegate;
}
// Visible for Sleuth instrumentation
public void setDelegate(Client delegate) {
this.delegate = delegate;
}
}

7
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/ribbon/LoadBalancerFeignClient.java

@ -37,7 +37,7 @@ public class LoadBalancerFeignClient implements Client { @@ -37,7 +37,7 @@ public class LoadBalancerFeignClient implements Client {
static final Request.Options DEFAULT_OPTIONS = new Request.Options();
private final Client delegate;
private Client delegate;
private CachingSpringLoadBalancerFactory lbClientFactory;
@ -116,6 +116,11 @@ public class LoadBalancerFeignClient implements Client { @@ -116,6 +116,11 @@ public class LoadBalancerFeignClient implements Client {
return this.delegate;
}
// Visible for Sleuth instrumentation
public void setDelegate(Client delegate) {
this.delegate = delegate;
}
private FeignLoadBalancer lbClient(String clientName) {
return this.lbClientFactory.create(clientName);
}

Loading…
Cancel
Save