Skip to content

Commit d06c8e3

Browse files
core: include what name resolver was used when it fails
1 parent 967cc64 commit d06c8e3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

core/src/main/java/io/grpc/internal/ManagedChannelImpl.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,8 @@ private class NameResolverListenerImpl implements NameResolver.Listener {
12521252
@Override
12531253
public void onAddresses(final List<EquivalentAddressGroup> servers, final Attributes config) {
12541254
if (servers.isEmpty()) {
1255-
onError(Status.UNAVAILABLE.withDescription("NameResolver returned an empty list"));
1255+
onError(Status.UNAVAILABLE.withDescription(
1256+
"Name resolver " + helper.nr + " returned an empty list"));
12561257
return;
12571258
}
12581259
if (logger.isLoggable(Level.FINE)) {

core/src/test/java/io/grpc/internal/ManagedChannelImplTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.google.common.collect.ImmutableList;
5252
import com.google.common.collect.ImmutableMap;
5353
import com.google.common.collect.Iterables;
54+
import com.google.common.truth.Truth;
5455
import com.google.common.util.concurrent.ListenableFuture;
5556
import com.google.common.util.concurrent.MoreExecutors;
5657
import com.google.common.util.concurrent.SettableFuture;
@@ -759,7 +760,7 @@ public void nameResolutionFailed_delayedTransportShutdownCancelsBackoff() {
759760

760761
@Test
761762
public void nameResolverReturnsEmptySubLists() {
762-
String errorDescription = "NameResolver returned an empty list";
763+
String errorDescription = "returned an empty list";
763764

764765
// Pass a FakeNameResolverFactory with an empty list
765766
createChannel();
@@ -769,7 +770,7 @@ public void nameResolverReturnsEmptySubLists() {
769770
verify(mockLoadBalancer).handleNameResolutionError(statusCaptor.capture());
770771
Status status = statusCaptor.getValue();
771772
assertSame(Status.Code.UNAVAILABLE, status.getCode());
772-
assertEquals(errorDescription, status.getDescription());
773+
Truth.assertThat(status.getDescription()).contains(errorDescription);
773774
}
774775

775776
@Test

0 commit comments

Comments
 (0)