2.2.x fix npe (#3085)

* fix: fix npe in routing and reverse the flag in observeListeners

* refactor: route -> routing
pull/3086/head
Liu Ziming 2 years ago committed by GitHub
parent 4176e8f6df
commit 7ca2f15ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -99,7 +99,7 @@ spring:
2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例)
如果没有配置使用ribbon默认的负载均衡算法ZoneAvoidanceRule
----
spring.cloud.governance.routeing.rule=RandomRule
spring.cloud.governance.routing.rule=RandomRule
----
在引入Istio配置转换模块的前提下标签路由模块支持对以下几种请求的元信息做路由

@ -90,7 +90,7 @@ If you use Spring Cloud Alibaba Governance Label Routing in your project, You ne
2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example)
If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule.
----
spring.cloud.governance.routeing.rule=RandomRule
spring.cloud.governance.routing.rule=RandomRule
----
With the introduction of Istio Resource Transform module, the label routing module supports routing of the following types of request meta-information:

@ -5,4 +5,4 @@ spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
spring.cloud.nacos.discovery.fail-fast=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
#spring.cloud.governance.router.rule=RandomRule
#spring.cloud.governance.routing.rule=RandomRule

@ -32,7 +32,7 @@
2.配置当没有路由规则时的负载均衡算法(以随机负载均衡算法为例)
如果没有配置使用ribbon默认的负载均衡算法ZoneAvoidanceRule
```yaml
spring.cloud.governance.routeing.rule=RandomRule
spring.cloud.governance.routing.rule=RandomRule
```
### 应用启动

@ -34,7 +34,7 @@ In the future, more components such as RestTemplate, Spring Cloud LoadBalancer a
2.Configure a load balance algorithm when there are no routing rules (RandomRule algorithm as an example)
If no configuration,use default ribbon load balance algorithm ZoneAvoidanceRule.
```yaml
spring.cloud.governance.routeing.rule=RandomRule
spring.cloud.governance.routing.rule=RandomRule
```
### Application Start

@ -16,6 +16,11 @@
package com.alibaba.cloud.routing;
import javax.annotation.PostConstruct;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.routing.util.LoadBalanceUtil;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@ -28,13 +33,20 @@ public class RoutingProperties {
/**
* Properties prefix.
*/
public static final String PROPERTY_PREFIX = "spring.cloud.governance.router";
public static final String PROPERTY_PREFIX = "spring.cloud.governance.routing";
/**
* Load Balance Rule.
*/
private String rule;
@PostConstruct
public void init() {
if (StringUtils.isEmpty(rule)) {
rule = LoadBalanceUtil.ZONE_AVOIDANCE_RULE;
}
}
public String getRule() {
return rule;
}

@ -56,7 +56,7 @@ public class PilotExchanger {
return;
}
Set<String> resourceName = ldsProtocol.getResourceNames();
if (CollectionUtils.isEmpty(resourceName)) {
if (!CollectionUtils.isEmpty(resourceName)) {
rdsProtocol.observeResource(resourceName, this::observeRoutes);
}

Loading…
Cancel
Save