diff --git a/java/core/src/main/java/com/google/protobuf/TextFormat.java b/java/core/src/main/java/com/google/protobuf/TextFormat.java index eb484f03200c..dfeeea418a4b 100644 --- a/java/core/src/main/java/com/google/protobuf/TextFormat.java +++ b/java/core/src/main/java/com/google/protobuf/TextFormat.java @@ -1537,6 +1537,7 @@ public enum SingularOverwritePolicy { private final SingularOverwritePolicy singularOverwritePolicy; private TextFormatParseInfoTree.Builder parseInfoTreeBuilder; private final int recursionLimit; + private Descriptor rootType; private Parser( TypeRegistry typeRegistry, @@ -1553,6 +1554,7 @@ private Parser( this.singularOverwritePolicy = singularOverwritePolicy; this.parseInfoTreeBuilder = parseInfoTreeBuilder; this.recursionLimit = recursionLimit; + this.rootType = null; } /** Returns a new instance of {@link Builder}. */ @@ -1754,6 +1756,7 @@ public void merge( throws ParseException { final Tokenizer tokenizer = new Tokenizer(input); MessageReflection.BuilderAdapter target = new MessageReflection.BuilderAdapter(builder); + rootType = target.getDescriptorForType(); List unknownFields = new ArrayList(); while (!tokenizer.atEnd()) {