From 9f94950e2064372901f3ca20b83c5f36be24906d Mon Sep 17 00:00:00 2001 From: chandlerc Date: Mon, 10 Apr 2023 14:33:12 -0700 Subject: [PATCH] Automated rollback of changelist 520827894. PiperOrigin-RevId: 523213865 --- src/google/protobuf/compiler/retention.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/compiler/retention.cc b/src/google/protobuf/compiler/retention.cc index fad5fd0da8..a8212cddf5 100644 --- a/src/google/protobuf/compiler/retention.cc +++ b/src/google/protobuf/compiler/retention.cc @@ -102,10 +102,13 @@ void ConvertToDynamicMessageAndStripOptions( const Descriptor* descriptor = pool.FindMessageTypeByName(m.GetTypeName()); std::vector path; - if (descriptor == nullptr) { + if (descriptor == nullptr || + descriptor->file()->pool() == DescriptorPool::generated_pool()) { // If the pool does not contain the descriptor, then this proto file does // not transitively depend on descriptor.proto, in which case we know there - // are no custom options to worry about. + // are no custom options to worry about. If we are working with the + // generated pool, then we can still access any custom options without + // having to resort to DynamicMessage. StripMessage(m, path, stripped_paths); } else { DynamicMessageFactory factory;