fix:fix circuitbreaker wrapper init error.

pull/96/head
skyehtzhang 3 years ago
parent 304d90e1b2
commit 1b60016972

@ -27,6 +27,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties;
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;
import org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient;
/**
@ -51,12 +52,20 @@ public class PolarisFeignBeanPostProcessor implements BeanPostProcessor, BeanFac
private Object wrapper(Object bean) {
if (isNeedWrap(bean)) {
if (bean instanceof RetryableFeignBlockingLoadBalancerClient) {
RetryableFeignBlockingLoadBalancerClient client = (RetryableFeignBlockingLoadBalancerClient) bean;
return new PolarisFeignBlockingLoadBalancerClient(createPolarisFeignClient(client.getDelegate()),
factory.getBean(BlockingLoadBalancerClient.class),
factory.getBean(LoadBalancerProperties.class),
factory.getBean(LoadBalancerClientFactory.class));
if (bean instanceof RetryableFeignBlockingLoadBalancerClient || bean instanceof FeignBlockingLoadBalancerClient) {
Client delegate;
if (bean instanceof RetryableFeignBlockingLoadBalancerClient) {
delegate = ((RetryableFeignBlockingLoadBalancerClient) bean).getDelegate();
}
else {
delegate = ((FeignBlockingLoadBalancerClient) bean).getDelegate();
}
if (delegate != null) {
return new PolarisFeignBlockingLoadBalancerClient(createPolarisFeignClient(delegate),
factory.getBean(BlockingLoadBalancerClient.class),
factory.getBean(LoadBalancerProperties.class),
factory.getBean(LoadBalancerClientFactory.class));
}
}
return createPolarisFeignClient((Client) bean);
}

Loading…
Cancel
Save