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

Loading…
Cancel
Save