core: include what name resolver was used when it fails

This commit is contained in:
Carl Mastrangelo 2018-10-11 13:39:20 -07:00 committed by GitHub
parent 967cc64770
commit d06c8e3bf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -1252,7 +1252,8 @@ final class ManagedChannelImpl extends ManagedChannel implements
@Override
public void onAddresses(final List<EquivalentAddressGroup> servers, final Attributes config) {
if (servers.isEmpty()) {
onError(Status.UNAVAILABLE.withDescription("NameResolver returned an empty list"));
onError(Status.UNAVAILABLE.withDescription(
"Name resolver " + helper.nr + " returned an empty list"));
return;
}
if (logger.isLoggable(Level.FINE)) {

View File

@ -51,6 +51,7 @@ import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.truth.Truth;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
@ -759,7 +760,7 @@ public class ManagedChannelImplTest {
@Test
public void nameResolverReturnsEmptySubLists() {
String errorDescription = "NameResolver returned an empty list";
String errorDescription = "returned an empty list";
// Pass a FakeNameResolverFactory with an empty list
createChannel();
@ -769,7 +770,7 @@ public class ManagedChannelImplTest {
verify(mockLoadBalancer).handleNameResolutionError(statusCaptor.capture());
Status status = statusCaptor.getValue();
assertSame(Status.Code.UNAVAILABLE, status.getCode());
assertEquals(errorDescription, status.getDescription());
Truth.assertThat(status.getDescription()).contains(errorDescription);
}
@Test