fix:fix circuit breaker bean load order bug when using Nacos discovery. (#1050)

pull/1057/head
Haotian Zhang 2 years ago committed by GitHub
parent 8534ee3523
commit 5750e510c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,3 +16,4 @@
- [build(deps): bump guava in /spring-cloud-tencent-dependencies](https://github.com/Tencent/spring-cloud-tencent/pull/1037)
- [fix:fix reporting bug when port is -1.](https://github.com/Tencent/spring-cloud-tencent/pull/1040)
- [fix:update guava version.](https://github.com/Tencent/spring-cloud-tencent/pull/1043)
- [fix:fix circuit breaker bean load order bug when using Nacos discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1050)

@ -31,7 +31,6 @@ import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
@ -85,7 +84,6 @@ public class PolarisCircuitBreakerAutoConfiguration {
}
@Bean
@ConditionalOnBean(RpcEnhancementReporterProperties.class)
@ConditionalOnMissingBean(CircuitBreakerConfigModifier.class)
public CircuitBreakerConfigModifier circuitBreakerConfigModifier(RpcEnhancementReporterProperties properties) {
return new CircuitBreakerConfigModifier(properties);

@ -30,7 +30,6 @@ import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.circuitbreaker.Customizer;
@ -76,7 +75,6 @@ public class ReactivePolarisCircuitBreakerAutoConfiguration {
}
@Bean
@ConditionalOnBean(RpcEnhancementReporterProperties.class)
@ConditionalOnMissingBean(CircuitBreakerConfigModifier.class)
public CircuitBreakerConfigModifier reactiveCircuitBreakerConfigModifier(RpcEnhancementReporterProperties properties) {
return new CircuitBreakerConfigModifier(properties);

@ -20,17 +20,13 @@ package com.tencent.cloud.polaris.router.config;
import java.util.List;
import com.tencent.cloud.common.pojo.PolarisServiceInstance;
import com.tencent.cloud.polaris.context.PolarisSDKContextManager;
import com.tencent.cloud.polaris.router.PolarisRouterServiceInstanceListSupplier;
import com.tencent.cloud.polaris.router.spi.RouterRequestInterceptor;
import com.tencent.cloud.polaris.router.spi.RouterResponseInterceptor;
import com.tencent.cloud.rpc.enhancement.transformer.InstanceTransformer;
import com.tencent.cloud.rpc.enhancement.transformer.PolarisInstanceTransformer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.ConditionalOnBlockingDiscoveryEnabled;
import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled;
import org.springframework.cloud.client.ConditionalOnReactiveDiscoveryEnabled;
@ -56,13 +52,6 @@ public class LoadBalancerConfiguration {
*/
private static final int REACTIVE_SERVICE_INSTANCE_SUPPLIER_ORDER = 193827465;
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(PolarisServiceInstance.class)
public InstanceTransformer instanceTransformer() {
return new PolarisInstanceTransformer();
}
@Configuration(proxyBeanMethods = false)
@ConditionalOnReactiveDiscoveryEnabled
@Order(REACTIVE_SERVICE_INSTANCE_SUPPLIER_ORDER)

@ -19,7 +19,6 @@
package com.tencent.cloud.plugin.discovery.adapter.config;
import com.tencent.cloud.plugin.discovery.adapter.transformer.NacosInstanceTransformer;
import com.tencent.cloud.polaris.router.config.ConditionalOnPolarisRouterEnabled;
import com.tencent.cloud.polaris.router.config.LoadBalancerConfiguration;
import com.tencent.cloud.rpc.enhancement.transformer.InstanceTransformer;
@ -43,7 +42,6 @@ public class NacosDiscoveryAdapterAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnPolarisRouterEnabled
@ConditionalOnClass(name = "com.alibaba.cloud.nacos.NacosServiceInstance")
public InstanceTransformer instanceTransformer() {
return new NacosInstanceTransformer();

@ -0,0 +1,2 @@
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
com.tencent.cloud.plugin.discovery.adapter.config.NacosDiscoveryAdapterAutoConfiguration

@ -20,7 +20,6 @@ package com.tencent.cloud.rpc.enhancement.config;
import java.util.Collections;
import java.util.List;
import com.tencent.cloud.common.pojo.PolarisServiceInstance;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.PolarisSDKContextManager;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
@ -54,6 +53,7 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@ -89,7 +89,7 @@ public class RpcEnhancementAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(PolarisServiceInstance.class)
@ConditionalOnMissingClass("com.alibaba.cloud.nacos.NacosServiceInstance")
public InstanceTransformer instanceTransformer() {
return new PolarisInstanceTransformer();
}

Loading…
Cancel
Save