Skip to content

Commit c0c9ff1

Browse files
kevinoconnor7copybara-github
authored andcommitted
Lazily parse the field options descriptor
This avoids a parsing cycle where fields on FieldOptions have options set on themselves. PiperOrigin-RevId: 518335401
1 parent 0d89d87 commit c0c9ff1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

protobuf/runtime/src/com/google/protobuf/Descriptors.m

+3-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,6 @@ - (instancetype)initWithData:(CGPFieldData *)data
358358
data_ = data;
359359
tag_ = TagFromData(data);
360360
javaType_ = [GetTypeObj(data->type)->javaType_ ordinal];
361-
fieldOptions_ = InitFieldOptions(data->optionsData);
362361
containingType_ = containingType;
363362
CGPFieldFixDefaultValue(self);
364363
}
@@ -425,6 +424,9 @@ - (id)getDefaultValue {
425424
- (ComGoogleProtobufDescriptorProtos_FieldOptions *)getOptions {
426425
if (fieldOptions_ != nil) {
427426
return fieldOptions_;
427+
} else if (data_->optionsData != NULL) {
428+
fieldOptions_ = InitFieldOptions(data_->optionsData);
429+
return fieldOptions_;
428430
} else {
429431
return [ComGoogleProtobufDescriptorProtos_FieldOptions getDefaultInstance];
430432
}

0 commit comments

Comments
 (0)