From d3035a3d5f7a1441807b1d114ee4d269133776a3 Mon Sep 17 00:00:00 2001
From: Yash Tibrewal <yashkt@google.com>
Date: Fri, 26 Apr 2019 12:38:36 -0700
Subject: [PATCH] Revert changes to optional

---
 .../client_channel/resolver_result_parsing.cc    | 16 ++++++++--------
 .../client_channel/resolver_result_parsing.h     |  4 ++--
 src/core/lib/gprpp/optional.h                    |  1 -
 3 files changed, 10 insertions(+), 11 deletions(-)

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 418c4deae9..35e54779c6 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 e44482419a..7307149496 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 2166fe4763..87d336ad6d 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;
-- 
GitLab