Revert "Add Type Checking On Channel Args"
diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc
index f141aab..ea6775a 100644
--- a/src/core/ext/filters/client_channel/client_channel.cc
+++ b/src/core/ext/filters/client_channel/client_channel.cc
@@ -327,14 +327,16 @@
if (chand->resolver_result != nullptr) {
if (chand->resolver != nullptr) {
// Find LB policy name.
- const char* lb_policy_name = grpc_channel_args_get_string(
+ const grpc_arg* channel_arg = grpc_channel_args_find(
chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
+ const char* lb_policy_name = grpc_channel_arg_get_string(channel_arg);
// Special case: If at least one balancer address is present, we use
// the grpclb policy, regardless of what the resolver actually specified.
- grpc_lb_addresses* addresses =
- grpc_channel_args_get_pointer<grpc_lb_addresses>(
- chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
- if (addresses != nullptr) {
+ channel_arg =
+ grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
+ if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
+ grpc_lb_addresses* addresses =
+ static_cast<grpc_lb_addresses*>(channel_arg->value.pointer.p);
bool found_balancer_address = false;
for (size_t i = 0; i < addresses->num_addresses; ++i) {
if (addresses->addresses[i].is_balancer) {
@@ -398,15 +400,18 @@
// The copy will be saved in chand->lb_policy_name below.
lb_policy_name_dup = gpr_strdup(lb_policy_name);
// Find service config.
- service_config_json = gpr_strdup(grpc_channel_args_get_string(
- chand->resolver_result, GRPC_ARG_SERVICE_CONFIG));
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
+ GRPC_ARG_SERVICE_CONFIG);
+ service_config_json =
+ gpr_strdup(grpc_channel_arg_get_string(channel_arg));
if (service_config_json != nullptr) {
grpc_core::UniquePtr<grpc_core::ServiceConfig> service_config =
grpc_core::ServiceConfig::Create(service_config_json);
if (service_config != nullptr) {
if (chand->enable_retries) {
- const char* server_uri = grpc_channel_args_get_string(
- chand->resolver_result, GRPC_ARG_SERVER_URI);
+ channel_arg = grpc_channel_args_find(chand->resolver_result,
+ GRPC_ARG_SERVER_URI);
+ const char* server_uri = grpc_channel_arg_get_string(channel_arg);
GPR_ASSERT(server_uri != nullptr);
grpc_uri* uri = grpc_uri_parse(server_uri, true);
GPR_ASSERT(uri->path[0] != '\0');
@@ -643,37 +648,45 @@
"client_channel");
grpc_client_channel_start_backup_polling(chand->interested_parties);
// Record max per-RPC retry buffer size.
- chand->per_rpc_retry_buffer_size = (size_t)grpc_channel_args_get_integer(
- args->channel_args, GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE,
- {DEFAULT_PER_RPC_RETRY_BUFFER_SIZE, 0, INT_MAX});
+ const grpc_arg* arg = grpc_channel_args_find(
+ args->channel_args, GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE);
+ chand->per_rpc_retry_buffer_size = (size_t)grpc_channel_arg_get_integer(
+ arg, {DEFAULT_PER_RPC_RETRY_BUFFER_SIZE, 0, INT_MAX});
// Record enable_retries.
- chand->enable_retries = grpc_channel_args_get_bool(
- args->channel_args, GRPC_ARG_ENABLE_RETRIES, true);
+ arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_ENABLE_RETRIES);
+ chand->enable_retries = grpc_channel_arg_get_bool(arg, true);
// Record client channel factory.
- grpc_client_channel_factory* client_channel_factory =
- grpc_channel_args_get_pointer<grpc_client_channel_factory>(
- args->channel_args, GRPC_ARG_CLIENT_CHANNEL_FACTORY);
- if (client_channel_factory == nullptr) {
+ arg = grpc_channel_args_find(args->channel_args,
+ GRPC_ARG_CLIENT_CHANNEL_FACTORY);
+ if (arg == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Missing or malformed client channel factory in args for client "
- "channel filter");
+ "Missing client channel factory in args for client channel filter");
}
- grpc_client_channel_factory_ref(client_channel_factory);
- chand->client_channel_factory = client_channel_factory;
- // Get server name to resolve, using proxy mapper if needed.
- char* server_uri =
- grpc_channel_args_get_string(args->channel_args, GRPC_ARG_SERVER_URI);
- if (server_uri == nullptr) {
+ if (arg->type != GRPC_ARG_POINTER) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
- "Missing or malformed server uri in args for client channel filter");
+ "client channel factory arg must be a pointer");
+ }
+ grpc_client_channel_factory_ref(
+ static_cast<grpc_client_channel_factory*>(arg->value.pointer.p));
+ chand->client_channel_factory =
+ static_cast<grpc_client_channel_factory*>(arg->value.pointer.p);
+ // Get server name to resolve, using proxy mapper if needed.
+ arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
+ if (arg == nullptr) {
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "Missing server uri in args for client channel filter");
+ }
+ if (arg->type != GRPC_ARG_STRING) {
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
+ "server uri arg must be a string");
}
char* proxy_name = nullptr;
grpc_channel_args* new_args = nullptr;
- grpc_proxy_mappers_map_name(server_uri, args->channel_args, &proxy_name,
- &new_args);
+ grpc_proxy_mappers_map_name(arg->value.string, args->channel_args,
+ &proxy_name, &new_args);
// Instantiate resolver.
chand->resolver = grpc_core::ResolverRegistry::CreateResolver(
- proxy_name != nullptr ? proxy_name : server_uri,
+ proxy_name != nullptr ? proxy_name : arg->value.string,
new_args != nullptr ? new_args : args->channel_args,
chand->interested_parties, chand->combiner);
if (proxy_name != nullptr) gpr_free(proxy_name);