Skip to content

Commit 9a38b3a

Browse files
evalon32tensorflow-copybara
authored andcommitted
Prepare code for breaking change in Protobuf C++ API.
Protobuf 6.30.0 will change the return types of Descriptor::name() and other methods to absl::string_view. This makes the code work both before and after such a change. PiperOrigin-RevId: 689864895
1 parent 1e16551 commit 9a38b3a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tensorflow_serving/util/class_registration.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ class ClassRegistry {
229229
static Status Create(const protobuf::Message& config,
230230
AdditionalFactoryArgs... args,
231231
std::unique_ptr<BaseClass>* result) {
232-
const string& config_proto_message_type =
233-
config.GetDescriptor()->full_name();
232+
std::string config_proto_message_type(config.GetDescriptor()->full_name());
234233
auto* factory = LookupFromMap(config_proto_message_type);
235234
if (factory == nullptr) {
236235
return errors::InvalidArgument(
@@ -352,13 +351,14 @@ class ClassRegistry {
352351
REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
353352
config_proto, ##__VA_ARGS__)
354353

355-
#define REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
356-
config_proto, ...) \
357-
static ::tensorflow::serving::internal::ClassRegistry< \
358-
RegistryName, BaseClass, ##__VA_ARGS__>::MapInserter \
359-
register_class_##cnt( \
360-
(config_proto::default_instance().GetDescriptor()->full_name()), \
361-
(new ::tensorflow::serving::internal::ClassRegistrationFactory< \
354+
#define REGISTER_CLASS_UNIQ(cnt, RegistryName, BaseClass, ClassCreator, \
355+
config_proto, ...) \
356+
static ::tensorflow::serving::internal::ClassRegistry< \
357+
RegistryName, BaseClass, ##__VA_ARGS__>::MapInserter \
358+
register_class_##cnt( \
359+
std::string( \
360+
config_proto::default_instance().GetDescriptor()->full_name()), \
361+
(new ::tensorflow::serving::internal::ClassRegistrationFactory< \
362362
BaseClass, ClassCreator, config_proto, ##__VA_ARGS__>));
363363

364364
} // namespace serving

0 commit comments

Comments
 (0)