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,6 +1312,8 @@ final class ManagedChannelImpl extends ManagedChannel implements
} }
} }
// Call LB only if it's not shutdown. If LB is shutdown, lbHelper won't match.
if (NameResolverListenerImpl.this.helper == ManagedChannelImpl.this.lbHelper) {
if (servers.isEmpty() && !helper.lb.canHandleEmptyAddressListFromNameResolution()) { if (servers.isEmpty() && !helper.lb.canHandleEmptyAddressListFromNameResolution()) {
handleErrorInSyncContext(Status.UNAVAILABLE.withDescription( handleErrorInSyncContext(Status.UNAVAILABLE.withDescription(
"Name resolver " + resolver + " returned an empty list")); "Name resolver " + resolver + " returned an empty list"));
@ -1324,6 +1322,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
} }
} }
} }
}
syncContext.execute(new NamesResolved()); syncContext.execute(new NamesResolved());
} }