Commit 776b3a8b authored by Adam Cozzette's avatar Adam Cozzette

Fixed infinite recursion problem with Java GeneratedMessageV3 (#5657)

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.
parent 7d9377e7
...@@ -710,19 +710,23 @@ public abstract class GeneratedMessageV3 extends AbstractMessage ...@@ -710,19 +710,23 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
return (BuilderType) this; return (BuilderType) this;
} }
@Override private BuilderType setUnknownFieldsInternal(final UnknownFieldSet unknownFields) {
public BuilderType setUnknownFields(final UnknownFieldSet unknownFields) {
this.unknownFields = unknownFields; this.unknownFields = unknownFields;
onChanged(); onChanged();
return (BuilderType) this; 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 * This method is obsolete, but we must retain it for compatibility with
* compatibility with older generated code. * older generated code.
*/ */
protected BuilderType setUnknownFieldsProto3(final UnknownFieldSet unknownFields) { protected BuilderType setUnknownFieldsProto3(final UnknownFieldSet unknownFields) {
return setUnknownFields(unknownFields); return setUnknownFieldsInternal(unknownFields);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment