Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 663919912
  • Loading branch information
protobuf-github-bot authored and zhangskz committed Sep 18, 2024
1 parent 5b0e543 commit 50a7745
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 82 deletions.
106 changes: 24 additions & 82 deletions java/core/src/main/java/com/google/protobuf/CodedInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

// -----------------------------------------------------------------

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ message ReservedAsMapFieldWithEnumValue {
// https://github.com/protocolbuffers/protobuf/issues/9785
message MapContainer {
map<string, string> my_map = 1;
map<uint32, string> m = 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,5 @@ message ReservedAsMapFieldWithEnumValue {
// https://github.com/protocolbuffers/protobuf/issues/9785
message MapContainer {
map<string, string> my_map = 1;
map<uint32, string> m = 3;
}
1 change: 1 addition & 0 deletions java/lite/src/test/java/com/google/protobuf/LiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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;
Expand Down

0 comments on commit 50a7745

Please sign in to comment.