Skip to content

Commit

Permalink
fix(alibaba#10585): selectInstances and selectOneHealthyInstance meth…
Browse files Browse the repository at this point in the history
…ods, if the parameter subscribe is true. Subscription is required when clientProxy.isSubscribe() is false.
  • Loading branch information
Bo-Qiu committed Jul 16, 2023
1 parent 156cd62 commit b446a9e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public List<Instance> selectInstances(String serviceName, String groupName, List
String clusterString = StringUtils.join(clusters, ",");
if (subscribe) {
serviceInfo = serviceInfoHolder.getServiceInfo(serviceName, groupName, clusterString);
if (null == serviceInfo) {
if (null == serviceInfo || !clientProxy.isSubscribed(serviceName, groupName, clusterString)) {
serviceInfo = clientProxy.subscribe(serviceName, groupName, clusterString);
}
} else {
Expand Down Expand Up @@ -368,7 +368,7 @@ public Instance selectOneHealthyInstance(String serviceName, String groupName, L
String clusterString = StringUtils.join(clusters, ",");
if (subscribe) {
ServiceInfo serviceInfo = serviceInfoHolder.getServiceInfo(serviceName, groupName, clusterString);
if (null == serviceInfo) {
if (null == serviceInfo || !clientProxy.isSubscribed(serviceName, groupName, clusterString)) {
serviceInfo = clientProxy.subscribe(serviceName, groupName, clusterString);
}
return Balancer.RandomByWeight.selectHost(serviceInfo);
Expand Down

0 comments on commit b446a9e

Please sign in to comment.