Skip to content

Commit

Permalink
fix more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaypujare committed Oct 5, 2023
1 parent da667a9 commit 6a1093b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions api/src/main/java/io/grpc/ManagedChannelRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -162,7 +161,7 @@ ManagedChannelBuilder<?> newChannelBuilder(NameResolverRegistry nameResolverRegi
.getNameResolverProvider(nameResolverRegistry, target);

Collection<Class<? extends SocketAddress>> nameResolverSocketAddressTypes
= (nameResolverProvider != null)
= (nameResolverProvider != null)
? nameResolverProvider.getProducedSocketAddressTypes() :
Collections.emptySet();
List<ManagedChannelProvider> providers = providers();
Expand Down
4 changes: 3 additions & 1 deletion api/src/test/java/io/grpc/NameResolverRegistryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,14 @@ public void newNameResolver_noProvider() {
public void baseProviders() {
Map<String, NameResolverProvider> providers =
NameResolverRegistry.getDefaultRegistry().providers();
assertThat(providers).hasSize(1);
assertThat(providers).hasSize(2);
// 2 name resolvers from grpclb and core, higher priority one is returned.
assertThat(providers.get("dns").getClass().getName())
.isEqualTo("io.grpc.grpclb.SecretGrpclbNameResolverProvider$Provider");
assertThat(NameResolverRegistry.getDefaultRegistry().asFactory().getDefaultScheme())
.isEqualTo("dns");
assertThat(providers.get("inprocess").getClass().getName())
.isEqualTo("io.grpc.inprocess.InProcessNameResolverProvider");
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/io/grpc/internal/ManagedChannelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ private static NameResolver getNameResolver(
= nameResolverProvider.getProducedSocketAddressTypes();
if (!channelTransportSocketAddressTypes.containsAll(nameResolverSocketAddressTypes)) {
throw new IllegalArgumentException(String.format(
"Address types of NameResolver '%s' for '%s' not supported by transport address types %s, nameResolverAddressTypes are %s",
nameResolverProvider.getDefaultScheme(), target, channelTransportSocketAddressTypes, nameResolverSocketAddressTypes));
"Address types of NameResolver '%s' for '%s' not supported by transport",
nameResolverProvider.getDefaultScheme(), target));
}
// Finding a NameResolver. Try using the target string as the URI. If that fails, try prepending
// "dns:///".
Expand Down

0 comments on commit 6a1093b

Please sign in to comment.