Skip to content

Commit

Permalink
core: Detect NameResolverProviders passed as Factories
Browse files Browse the repository at this point in the history
This may help some to move closer to Providers. It especially helps
cases where `NameResolverFactory`s aren't returning `InetSocketAddress`,
as it allows them to override `getProducedSocketAddressTypes()`, which
will now fail starting in 15fc70b.
  • Loading branch information
ejona86 committed Nov 21, 2023
1 parent c6d448e commit 3b92333
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,11 @@ public ManagedChannelImplBuilder nameResolverFactory(NameResolver.Factory resolv
directServerAddress);
if (resolverFactory != null) {
NameResolverRegistry reg = new NameResolverRegistry();
reg.register(new NameResolverFactoryToProviderFacade(resolverFactory));
if (resolverFactory instanceof NameResolverProvider) {
reg.register((NameResolverProvider) resolverFactory);
} else {
reg.register(new NameResolverFactoryToProviderFacade(resolverFactory));
}
this.nameResolverRegistry = reg;
} else {
this.nameResolverRegistry = NameResolverRegistry.getDefaultRegistry();
Expand Down

0 comments on commit 3b92333

Please sign in to comment.