Skip to content

Commit

Permalink
Fixed infinite recursion problem with Java GeneratedMessageV3 (#5657)
Browse files Browse the repository at this point in the history
GeneratedMessageV3#setUnknownFieldsProto3 was trying to delegate to
setUnknownFields but was inadvertently resulting in infinite recursion.
This commit makes setUnknownFields and setUnknownFieldsProto3 delegate
to a common private method to fix the problem and avoid confusion.
  • Loading branch information
acozzette committed Feb 1, 2019
1 parent 7d9377e commit 776b3a8
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -710,19 +710,23 @@ public BuilderType addRepeatedField(final FieldDescriptor field, final Object va
return (BuilderType) this;
}

@Override
public BuilderType setUnknownFields(final UnknownFieldSet unknownFields) {
private BuilderType setUnknownFieldsInternal(final UnknownFieldSet unknownFields) {
this.unknownFields = unknownFields;
onChanged();
return (BuilderType) this;
}

@Override
public BuilderType setUnknownFields(final UnknownFieldSet unknownFields) {
return setUnknownFieldsInternal(unknownFields);
}

/**
* Delegates to setUnknownFields. This method is obsolete, but we must retain it for
* compatibility with older generated code.
* This method is obsolete, but we must retain it for compatibility with
* older generated code.
*/
protected BuilderType setUnknownFieldsProto3(final UnknownFieldSet unknownFields) {
return setUnknownFields(unknownFields);
return setUnknownFieldsInternal(unknownFields);
}

@Override
Expand Down

0 comments on commit 776b3a8

Please sign in to comment.