diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.cc b/src/core/ext/filters/client_channel/resolver_result_parsing.cc index 418c4deae9a6820ff2201c325c4dd1def97e37ce..35e54779c69aed587d0100b87c42ff5497d1baaa 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.cc +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.cc @@ -416,8 +416,8 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, "field:retryThrottling error:Type should be object")); continue; } - Optional<int> max_milli_tokens; - Optional<int> milli_token_ratio; + Optional<int> max_milli_tokens = Optional<int>(); + Optional<int> milli_token_ratio = Optional<int>(); for (grpc_json* sub_field = field->child; sub_field != nullptr; sub_field = sub_field->next) { if (sub_field->key == nullptr) continue; @@ -492,20 +492,20 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, } } } + ClientChannelGlobalParsedObject::RetryThrottling data; if (!max_milli_tokens.has_value()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:retryThrottling field:maxTokens error:Not found")); + } else { + data.max_milli_tokens = max_milli_tokens.value(); } if (!milli_token_ratio.has_value()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:retryThrottling field:tokenRatio error:Not found")); - } - if (error_list.size() == 0) { - ClientChannelGlobalParsedObject::RetryThrottling data; - data.max_milli_tokens = max_milli_tokens.value(); + } else { data.milli_token_ratio = milli_token_ratio.value(); - retry_throttling.set(data); } + retry_throttling.set(data); } if (strcmp(field->key, "healthCheckConfig") == 0) { if (health_check_service_name != nullptr) { @@ -535,7 +535,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, grpc_error** error) { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); InlinedVector<grpc_error*, 4> error_list; - Optional<bool> wait_for_ready; + Optional<bool> wait_for_ready = Optional<bool>(); grpc_millis timeout = 0; UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy; for (grpc_json* field = json->child; field != nullptr; field = field->next) { diff --git a/src/core/ext/filters/client_channel/resolver_result_parsing.h b/src/core/ext/filters/client_channel/resolver_result_parsing.h index e44482419aebf407153917620d768fffed4e4f08..7307149496f8d77666cb15604db8177dfd8b0133 100644 --- a/src/core/ext/filters/client_channel/resolver_result_parsing.h +++ b/src/core/ext/filters/client_channel/resolver_result_parsing.h @@ -74,7 +74,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig { RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_; UniquePtr<char> parsed_deprecated_lb_policy_; Optional<RetryThrottling> retry_throttling_; - const char* health_check_service_name_ = nullptr; + const char* health_check_service_name_; }; class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig { @@ -173,7 +173,7 @@ class ProcessedResolverResult { // Retry throttle data. Optional<ClientChannelGlobalParsedObject::RetryThrottling> retry_throttle_data_; - const char* health_check_service_name_; + const char* health_check_service_name_ = nullptr; }; } // namespace internal diff --git a/src/core/lib/gprpp/optional.h b/src/core/lib/gprpp/optional.h index 2166fe4763a7e7f12a03eb945720c5a796b5469b..87d336ad6d0a339232d83e170229abd49e0c9a16 100644 --- a/src/core/lib/gprpp/optional.h +++ b/src/core/lib/gprpp/optional.h @@ -26,7 +26,6 @@ namespace grpc_core { template <typename T> class Optional { public: - Optional() { value_ = T(); } void set(const T& val) { value_ = val; set_ = true;