Skip to content

Commit

Permalink
Fix attributes being overwritten.
Browse files Browse the repository at this point in the history
  • Loading branch information
voidzcy committed Jan 28, 2020
1 parent f02a7fa commit 19d2d7c
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions core/src/main/java/io/grpc/internal/DnsNameResolver.java
Expand Up @@ -300,11 +300,9 @@ public void run() {
}

ResolutionResult.Builder resultBuilder = ResolutionResult.newBuilder().setAddresses(servers);
Attributes.Builder attributesBuilder = Attributes.newBuilder();
if (!resolutionResults.balancerAddresses.isEmpty()) {
resultBuilder.setAttributes(
Attributes.newBuilder()
.set(GrpcAttributes.ATTR_LB_ADDRS, resolutionResults.balancerAddresses)
.build());
attributesBuilder.set(GrpcAttributes.ATTR_LB_ADDRS, resolutionResults.balancerAddresses);
}
if (!resolutionResults.txtRecords.isEmpty()) {
ConfigOrError rawServiceConfig =
Expand All @@ -319,17 +317,14 @@ public void run() {
Map<String, ?> verifiedRawServiceConfig = (Map<String, ?>) rawServiceConfig.getConfig();
ConfigOrError parsedServiceConfig =
serviceConfigParser.parseServiceConfig(verifiedRawServiceConfig);
resultBuilder
.setAttributes(
Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, verifiedRawServiceConfig)
.build())
.setServiceConfig(parsedServiceConfig);
resultBuilder.setServiceConfig(parsedServiceConfig);
attributesBuilder
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, verifiedRawServiceConfig);
}
} else {
logger.log(Level.FINE, "No TXT records found for {0}", new Object[]{host});
}
savedListener.onResult(resultBuilder.build());
savedListener.onResult(resultBuilder.setAttributes(attributesBuilder.build()).build());
}
}

Expand Down

0 comments on commit 19d2d7c

Please sign in to comment.