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 e673479 commit b704498
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 84 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 @@ -223,13 +223,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 @@ -699,26 +721,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 @@ -1411,26 +1413,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 @@ -2176,26 +2158,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 @@ -3307,26 +3269,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 @@ -99,5 +99,6 @@ message ReservedAsMapFieldWithEnumValue {

// https://github.com/protocolbuffers/protobuf/issues/9785
message MapContainer {
map<string,string> my_map = 1;
map<string, string> my_map = 1;
map<uint32, string> m = 3;
}
3 changes: 2 additions & 1 deletion java/core/src/test/proto/com/google/protobuf/map_test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ message ReservedAsMapFieldWithEnumValue {

// https://github.com/protocolbuffers/protobuf/issues/9785
message MapContainer {
map<string,string> my_map = 1;
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 b704498

Please sign in to comment.