diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 7b967461525..ef958ab45b1 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -36,6 +36,8 @@ namespace grpc_core { struct ResolverArgs { /// The parsed URI to resolve. URI uri; + /// The URI string. + std::string uri_string; /// Channel args to be included in resolver results. const grpc_channel_args* args = nullptr; /// Used to drive I/O in the name resolution process. diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc index 42b69bbb2ee..b1d0ee21a59 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.cc +++ b/src/core/ext/filters/client_channel/resolver_registry.cc @@ -73,7 +73,7 @@ class RegistryState { ResolverFactory* factory = tmp_uri.ok() ? LookupResolverFactory(tmp_uri->scheme()) : nullptr; if (factory != nullptr) { - *uri = *tmp_uri; + *uri = std::move(*tmp_uri); return factory; } *canonical_target = absl::StrCat(default_prefix_.get(), target); @@ -81,7 +81,7 @@ class RegistryState { factory = tmp_uri2.ok() ? LookupResolverFactory(tmp_uri2->scheme()) : nullptr; if (factory != nullptr) { - *uri = *tmp_uri2; + *uri = std::move(*tmp_uri2); return factory; } if (!tmp_uri.ok() || !tmp_uri2.ok()) { @@ -158,18 +158,16 @@ OrphanablePtr ResolverRegistry::CreateResolver( std::shared_ptr work_serializer, std::unique_ptr result_handler) { GPR_ASSERT(g_state != nullptr); - std::string canonical_target; ResolverArgs resolver_args; ResolverFactory* factory = g_state->FindResolverFactory( - target, &resolver_args.uri, &canonical_target); + target, &resolver_args.uri, &resolver_args.uri_string); + if (factory == nullptr) return nullptr; + if (resolver_args.uri_string.empty()) resolver_args.uri_string = target; resolver_args.args = args; resolver_args.pollset_set = pollset_set; resolver_args.work_serializer = std::move(work_serializer); resolver_args.result_handler = std::move(result_handler); - OrphanablePtr resolver = - factory == nullptr ? nullptr - : factory->CreateResolver(std::move(resolver_args)); - return resolver; + return factory->CreateResolver(std::move(resolver_args)); } std::string ResolverRegistry::GetDefaultAuthority(absl::string_view target) {