Skip to content

Commit 50a7745

Browse files
protobuf-github-botzhangskz
authored andcommitted
Internal change
PiperOrigin-RevId: 663919912
1 parent 5b0e543 commit 50a7745

File tree

4 files changed

+27
-82
lines changed

4 files changed

+27
-82
lines changed

java/core/src/main/java/com/google/protobuf/CodedInputStream.java

Lines changed: 24 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,35 @@ public abstract boolean skipField(final int tag, final CodedOutputStream output)
224224
* Reads and discards an entire message. This will read either until EOF or until an endgroup tag,
225225
* whichever comes first.
226226
*/
227-
public abstract void skipMessage() throws IOException;
227+
public void skipMessage() throws IOException {
228+
while (true) {
229+
final int tag = readTag();
230+
if (tag == 0) {
231+
return;
232+
}
233+
boolean fieldSkipped = skipField(tag);
234+
if (!fieldSkipped) {
235+
return;
236+
}
237+
}
238+
}
228239

229240
/**
230241
* Reads an entire message and writes it to output in wire format. This will read either until EOF
231242
* or until an endgroup tag, whichever comes first.
232243
*/
233-
public abstract void skipMessage(CodedOutputStream output) throws IOException;
244+
public void skipMessage(CodedOutputStream output) throws IOException {
245+
while (true) {
246+
final int tag = readTag();
247+
if (tag == 0) {
248+
return;
249+
}
250+
boolean fieldSkipped = skipField(tag, output);
251+
if (!fieldSkipped) {
252+
return;
253+
}
254+
}
255+
}
234256

235257
// -----------------------------------------------------------------
236258

@@ -700,26 +722,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I
700722
}
701723
}
702724

703-
@Override
704-
public void skipMessage() throws IOException {
705-
while (true) {
706-
final int tag = readTag();
707-
if (tag == 0 || !skipField(tag)) {
708-
return;
709-
}
710-
}
711-
}
712-
713-
@Override
714-
public void skipMessage(CodedOutputStream output) throws IOException {
715-
while (true) {
716-
final int tag = readTag();
717-
if (tag == 0 || !skipField(tag, output)) {
718-
return;
719-
}
720-
}
721-
}
722-
723725
// -----------------------------------------------------------------
724726

725727
@Override
@@ -1412,26 +1414,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I
14121414
}
14131415
}
14141416

1415-
@Override
1416-
public void skipMessage() throws IOException {
1417-
while (true) {
1418-
final int tag = readTag();
1419-
if (tag == 0 || !skipField(tag)) {
1420-
return;
1421-
}
1422-
}
1423-
}
1424-
1425-
@Override
1426-
public void skipMessage(CodedOutputStream output) throws IOException {
1427-
while (true) {
1428-
final int tag = readTag();
1429-
if (tag == 0 || !skipField(tag, output)) {
1430-
return;
1431-
}
1432-
}
1433-
}
1434-
14351417
// -----------------------------------------------------------------
14361418

14371419
@Override
@@ -2178,26 +2160,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I
21782160
}
21792161
}
21802162

2181-
@Override
2182-
public void skipMessage() throws IOException {
2183-
while (true) {
2184-
final int tag = readTag();
2185-
if (tag == 0 || !skipField(tag)) {
2186-
return;
2187-
}
2188-
}
2189-
}
2190-
2191-
@Override
2192-
public void skipMessage(CodedOutputStream output) throws IOException {
2193-
while (true) {
2194-
final int tag = readTag();
2195-
if (tag == 0 || !skipField(tag, output)) {
2196-
return;
2197-
}
2198-
}
2199-
}
2200-
22012163
/** Collects the bytes skipped and returns the data in a ByteBuffer. */
22022164
private class SkippedDataSink implements RefillCallback {
22032165
private int lastPos = pos;
@@ -3325,26 +3287,6 @@ public boolean skipField(final int tag, final CodedOutputStream output) throws I
33253287
}
33263288
}
33273289

3328-
@Override
3329-
public void skipMessage() throws IOException {
3330-
while (true) {
3331-
final int tag = readTag();
3332-
if (tag == 0 || !skipField(tag)) {
3333-
return;
3334-
}
3335-
}
3336-
}
3337-
3338-
@Override
3339-
public void skipMessage(CodedOutputStream output) throws IOException {
3340-
while (true) {
3341-
final int tag = readTag();
3342-
if (tag == 0 || !skipField(tag, output)) {
3343-
return;
3344-
}
3345-
}
3346-
}
3347-
33483290
// -----------------------------------------------------------------
33493291

33503292
@Override

java/core/src/test/proto/com/google/protobuf/map_lite_test.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ message ReservedAsMapFieldWithEnumValue {
115115
// https://github.com/protocolbuffers/protobuf/issues/9785
116116
message MapContainer {
117117
map<string, string> my_map = 1;
118+
map<uint32, string> m = 3;
118119
}

java/core/src/test/proto/com/google/protobuf/map_test.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,5 @@ message ReservedAsMapFieldWithEnumValue {
114114
// https://github.com/protocolbuffers/protobuf/issues/9785
115115
message MapContainer {
116116
map<string, string> my_map = 1;
117+
map<uint32, string> m = 3;
117118
}

java/lite/src/test/java/com/google/protobuf/LiteTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.google.protobuf.UnittestLite.TestHugeFieldNumbersLite;
3030
import com.google.protobuf.UnittestLite.TestNestedExtensionLite;
3131
import com.google.protobuf.testing.Proto3TestingLite.Proto3MessageLite;
32+
import map_lite_test.MapTestProto.MapContainer;
3233
import map_lite_test.MapTestProto.TestMap;
3334
import map_lite_test.MapTestProto.TestMap.MessageValue;
3435
import protobuf_unittest.NestedExtensionLite;

0 commit comments

Comments
 (0)