From 939338d2259a1456124af49ee1cb44e7e87af469 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 16 Aug 2024 16:57:47 -0700 Subject: [PATCH] Internal change PiperOrigin-RevId: 663919912 --- .../com/google/protobuf/CodedInputStream.java | 106 ++++-------------- .../com/google/protobuf/map_lite_test.proto | 1 + .../proto/com/google/protobuf/map_test.proto | 1 + .../java/com/google/protobuf/LiteTest.java | 1 + 4 files changed, 27 insertions(+), 82 deletions(-) diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java index 6fb96afa4bb4..4772b7058907 100644 --- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java +++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java @@ -224,13 +224,35 @@ public abstract boolean skipField(final int tag, final CodedOutputStream output) * Reads and discards an entire message. This will read either until EOF or until an endgroup tag, * whichever comes first. */ - public abstract void skipMessage() throws IOException; + public void skipMessage() throws IOException { + while (true) { + final int tag = readTag(); + if (tag == 0) { + return; + } + boolean fieldSkipped = skipField(tag); + if (!fieldSkipped) { + return; + } + } + } /** * Reads an entire message and writes it to output in wire format. This will read either until EOF * or until an endgroup tag, whichever comes first. */ - public abstract void skipMessage(CodedOutputStream output) throws IOException; + public void skipMessage(CodedOutputStream output) throws IOException { + while (true) { + final int tag = readTag(); + if (tag == 0) { + return; + } + boolean fieldSkipped = skipField(tag, output); + if (!fieldSkipped) { + return; + } + } + } // ----------------------------------------------------------------- @@ -700,26 +722,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I } } - @Override - public void skipMessage() throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag)) { - return; - } - } - } - - @Override - public void skipMessage(CodedOutputStream output) throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag, output)) { - return; - } - } - } - // ----------------------------------------------------------------- @Override @@ -1412,26 +1414,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I } } - @Override - public void skipMessage() throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag)) { - return; - } - } - } - - @Override - public void skipMessage(CodedOutputStream output) throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag, output)) { - return; - } - } - } - // ----------------------------------------------------------------- @Override @@ -2178,26 +2160,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I } } - @Override - public void skipMessage() throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag)) { - return; - } - } - } - - @Override - public void skipMessage(CodedOutputStream output) throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag, output)) { - return; - } - } - } - /** Collects the bytes skipped and returns the data in a ByteBuffer. */ private class SkippedDataSink implements RefillCallback { private int lastPos = pos; @@ -3325,26 +3287,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I } } - @Override - public void skipMessage() throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag)) { - return; - } - } - } - - @Override - public void skipMessage(CodedOutputStream output) throws IOException { - while (true) { - final int tag = readTag(); - if (tag == 0 || !skipField(tag, output)) { - return; - } - } - } - // ----------------------------------------------------------------- @Override diff --git a/java/core/src/test/proto/com/google/protobuf/map_lite_test.proto b/java/core/src/test/proto/com/google/protobuf/map_lite_test.proto index 610bef866852..c40ea5461efa 100644 --- a/java/core/src/test/proto/com/google/protobuf/map_lite_test.proto +++ b/java/core/src/test/proto/com/google/protobuf/map_lite_test.proto @@ -115,4 +115,5 @@ message ReservedAsMapFieldWithEnumValue { // https://github.com/protocolbuffers/protobuf/issues/9785 message MapContainer { map my_map = 1; + map m = 3; } diff --git a/java/core/src/test/proto/com/google/protobuf/map_test.proto b/java/core/src/test/proto/com/google/protobuf/map_test.proto index 4d1ac677e638..80bdc0d8532d 100644 --- a/java/core/src/test/proto/com/google/protobuf/map_test.proto +++ b/java/core/src/test/proto/com/google/protobuf/map_test.proto @@ -114,4 +114,5 @@ message ReservedAsMapFieldWithEnumValue { // https://github.com/protocolbuffers/protobuf/issues/9785 message MapContainer { map my_map = 1; + map m = 3; } diff --git a/java/lite/src/test/java/com/google/protobuf/LiteTest.java b/java/lite/src/test/java/com/google/protobuf/LiteTest.java index 411bc63f087f..13050b65d05b 100644 --- a/java/lite/src/test/java/com/google/protobuf/LiteTest.java +++ b/java/lite/src/test/java/com/google/protobuf/LiteTest.java @@ -31,6 +31,7 @@ import com.google.protobuf.UnittestLite.TestHugeFieldNumbersLite; import com.google.protobuf.UnittestLite.TestNestedExtensionLite; import com.google.protobuf.testing.Proto3TestingLite.Proto3MessageLite; +import map_lite_test.MapTestProto.MapContainer; import map_lite_test.MapTestProto.TestMap; import map_lite_test.MapTestProto.TestMap.MessageValue; import protobuf_unittest.NestedExtensionLite;