diff options
author | Yuchen Zeng <zyc@google.com> | 2016-09-29 15:47:37 -0700 |
---|---|---|
committer | Yuchen Zeng <zyc@google.com> | 2016-09-29 15:47:37 -0700 |
commit | 6679d78997a69940cbb6da5190b02a97ae053935 (patch) | |
tree | ea24788845e1509fe0f58e32687c168f03d7cf56 /test | |
parent | 942c264861dedd8020fc18d65933e8f4f57e3e46 (diff) |
Handle partially exposed reflection service
Diffstat (limited to 'test')
-rw-r--r-- | test/cpp/util/proto_file_parser.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/cpp/util/proto_file_parser.cc b/test/cpp/util/proto_file_parser.cc index 0c88c24448..f173ddd49e 100644 --- a/test/cpp/util/proto_file_parser.cc +++ b/test/cpp/util/proto_file_parser.cc @@ -36,6 +36,7 @@ #include <algorithm> #include <iostream> #include <sstream> +#include <unordered_set> #include <grpc++/support/config.h> @@ -87,6 +88,7 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel, reflection_db_->GetServices(&service_list); } + std::unordered_set<grpc::string> known_services; if (!protofiles.empty()) { source_tree_.MapPath("", proto_path); error_printer_.reset(new ErrorPrinter(this)); @@ -100,6 +102,7 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel, if (file_desc) { for (int i = 0; i < file_desc->service_count(); i++) { service_desc_list_.push_back(file_desc->service(i)); + known_services.insert(file_desc->service(i)->full_name()); } } else { std::cerr << file_name << " not found" << std::endl; @@ -127,9 +130,12 @@ ProtoFileParser::ProtoFileParser(std::shared_ptr<grpc::Channel> channel, dynamic_factory_.reset(new protobuf::DynamicMessageFactory(desc_pool_.get())); for (auto it = service_list.begin(); it != service_list.end(); it++) { - if (const protobuf::ServiceDescriptor* service_desc = - desc_pool_->FindServiceByName(*it)) { - service_desc_list_.push_back(service_desc); + if (known_services.find(*it) == known_services.end()) { + if (const protobuf::ServiceDescriptor* service_desc = + desc_pool_->FindServiceByName(*it)) { + service_desc_list_.push_back(service_desc); + known_services.insert(*it); + } } } } |