Skip to content

Commit

Permalink
修正Group为空的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HaojunRen committed Jul 9, 2019
1 parent 43e414f commit cac3062
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ public String getRegion() {

@Override
public String getServerGroupKey(Server server) {
return getServerMetadata(server).get(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY);
String groupKey = getServerMetadata(server).get(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY);

if (StringUtils.isEmpty(groupKey)) {
groupKey = DiscoveryConstant.GROUP;
}

return groupKey;
}

@Override
Expand Down Expand Up @@ -227,7 +233,13 @@ public Map<String, String> getInstanceMetadata(ServiceInstance serviceInstance)

@Override
public String getInstanceGroupKey(ServiceInstance serviceInstance) {
return getInstanceMetadata(serviceInstance).get(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY);
String groupKey = getInstanceMetadata(serviceInstance).get(DiscoveryConstant.SPRING_APPLICATION_GROUP_KEY);

if (StringUtils.isEmpty(groupKey)) {
groupKey = DiscoveryConstant.GROUP;
}

return groupKey;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public void onRegister(Registration registration) {
public void onDeregister(Registration registration) {
for (RegisterListener registerListener : registerListenerList) {
registerListener.onDeregister(registration);

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ spring.application.strategy.trace.debug.enabled=true
# spring.application.strategy.hystrix.threadlocal.supported=true

# Spring cloud gateway config
# 跟Hystrix会冲突。开启Hystrix后,下面项必须注释掉
# spring.cloud.gateway.discovery.locator.enabled=true
spring.cloud.gateway.discovery.locator.lowerCaseServiceId=true
spring.cloud.gateway.routes[0].id=discovery-springcloud-example-a
Expand Down

0 comments on commit cac3062

Please sign in to comment.