Skip to content

Commit

Permalink
[ISSUE #42] 没有可用服务时,客户端线程会hang住 (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: zhaojian15 <zhaojian15@baidu.com>
  • Loading branch information
stan9333 and zhaojian15 authored Apr 19, 2023
1 parent 3f6a646 commit 017665b
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 017665b

Please # to comment.