Make Java-lite reject unmatched end-group tag.
This brings it into conformance with our spec and other languages.
PiperOrigin-RevId: 702432195
diff --git a/conformance/failure_list_java_lite.txt b/conformance/failure_list_java_lite.txt
index 39a0f21..1494114 100644
--- a/conformance/failure_list_java_lite.txt
+++ b/conformance/failure_list_java_lite.txt
@@ -6,7 +6,3 @@
Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
Required.*.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE # Should have failed to parse, but didn't.
-Required.*.ProtobufInput.UnmatchedEndGroup # Should have failed to parse, but didn't.
-Required.*.ProtobufInput.UnmatchedEndGroupUnknown # Should have failed to parse, but didn't.
-Required.*.ProtobufInput.UnmatchedEndGroupWithData # Should have failed to parse, but didn't.
-Required.*.ProtobufInput.UnmatchedEndGroupWrongType # Should have failed to parse, but didn't.
diff --git a/java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java b/java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java
index 80602b1..5e2683d 100644
--- a/java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java
+++ b/java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java
@@ -93,6 +93,9 @@
addGroup(unknownFields, fieldNumber, toImmutable(subFields));
return true;
case WireFormat.WIRETYPE_END_GROUP:
+ if (currentDepth == 0) {
+ throw InvalidProtocolBufferException.invalidEndTag();
+ }
return false;
default:
throw InvalidProtocolBufferException.invalidWireType();