core: reorder code in NameResolver.Listener.onAddress()

This commit is contained in:
ZHANG Dapeng 2019-03-13 16:54:10 -07:00 committed by GitHub
parent 60e988dc20
commit 283f04983b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 9 deletions

View File

@ -1295,10 +1295,6 @@ final class ManagedChannelImpl extends ManagedChannel implements
channelLogger.log(ChannelLogLevel.INFO, "Service config changed"); channelLogger.log(ChannelLogLevel.INFO, "Service config changed");
lastServiceConfig = serviceConfig; lastServiceConfig = serviceConfig;
} }
// Call LB only if it's not shutdown. If LB is shutdown, lbHelper won't match.
if (NameResolverListenerImpl.this.helper != ManagedChannelImpl.this.lbHelper) {
return;
}
nameResolverBackoffPolicy = null; nameResolverBackoffPolicy = null;
@ -1316,11 +1312,14 @@ final class ManagedChannelImpl extends ManagedChannel implements
} }
} }
if (servers.isEmpty() && !helper.lb.canHandleEmptyAddressListFromNameResolution()) { // Call LB only if it's not shutdown. If LB is shutdown, lbHelper won't match.
handleErrorInSyncContext(Status.UNAVAILABLE.withDescription( if (NameResolverListenerImpl.this.helper == ManagedChannelImpl.this.lbHelper) {
"Name resolver " + resolver + " returned an empty list")); if (servers.isEmpty() && !helper.lb.canHandleEmptyAddressListFromNameResolution()) {
} else { handleErrorInSyncContext(Status.UNAVAILABLE.withDescription(
helper.lb.handleResolvedAddressGroups(servers, config); "Name resolver " + resolver + " returned an empty list"));
} else {
helper.lb.handleResolvedAddressGroups(servers, config);
}
} }
} }
} }