Skip to content

Commit

Permalink
[ISSUE #42] 没有可用服务时,客户端线程会hang住
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojian15 committed Apr 19, 2023
1 parent 3f6a646 commit ea97821
Showing 1 changed file with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,21 @@ private void doWatch(Listener2 listener) {

private void notifyListener(Listener2 listener, InstancesResponse response) {
ServiceInstances serviceInstances = response.toServiceInstances();
if (!serviceInstances.getInstances().isEmpty()) {
List<EquivalentAddressGroup> equivalentAddressGroups = serviceInstances.getInstances()
.stream()
.map(this::buildEquivalentAddressGroup)
.collect(Collectors.toList());
List<EquivalentAddressGroup> equivalentAddressGroups = serviceInstances.getInstances()
.stream()
.map(this::buildEquivalentAddressGroup)
.collect(Collectors.toList());

Attributes.Builder builder = Attributes.newBuilder();
Attributes.Builder builder = Attributes.newBuilder();

if (sourceService != null) {
builder.set(Common.SOURCE_SERVICE_INFO, sourceService);
}

listener.onResult(ResolutionResult.newBuilder()
.setAddresses(equivalentAddressGroups)
.setAttributes(builder.build())
.build());
if (sourceService != null) {
builder.set(Common.SOURCE_SERVICE_INFO, sourceService);
}

listener.onResult(ResolutionResult.newBuilder()
.setAddresses(equivalentAddressGroups)
.setAttributes(builder.build())
.build());
}

@Override
Expand Down

0 comments on commit ea97821

Please # to comment.