Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 653615736
  • Loading branch information
protobuf-github-bot authored and zhangskz committed Sep 18, 2024
1 parent b704498 commit 850fcce
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
@CheckReturnValue
final class ArrayDecoders {

private ArrayDecoders() {
}
private ArrayDecoders() {}

/**
* A helper used to return multiple values in a Java function. Java doesn't natively support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public InvalidWireTypeException(String description) {
static InvalidProtocolBufferException recursionLimitExceeded() {
return new InvalidProtocolBufferException(
"Protocol message had too many levels of nesting. May be malicious. "
+ "Use CodedInputStream.setRecursionLimit() to increase the depth limit.");
+ "Use setRecursionLimit() to increase the recursion depth limit.");
}

static InvalidProtocolBufferException sizeLimitExceeded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3006,6 +3006,7 @@ private <UT, UB, ET extends FieldDescriptorLite<ET>> void mergeFromHelper(
unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
}
// Unknown field.

if (unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
continue;
}
Expand Down Expand Up @@ -3381,6 +3382,7 @@ private <UT, UB, ET extends FieldDescriptorLite<ET>> void mergeFromHelper(
if (unknownFields == null) {
unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
}

if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
return;
}
Expand All @@ -3397,6 +3399,7 @@ private <UT, UB, ET extends FieldDescriptorLite<ET>> void mergeFromHelper(
if (unknownFields == null) {
unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
}

if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ boolean parseMessageSetItemOrUnknownField(
reader, extension, extensionRegistry, extensions);
return true;
} else {

return unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ abstract class UnknownFieldSchema<T, B> {
/** Marks unknown fields as immutable. */
abstract void makeImmutable(Object message);

/** Merges one field into the unknown fields. */
final boolean mergeOneFieldFrom(B unknownFields, Reader reader) throws IOException {
int tag = reader.getTag();
int fieldNumber = WireFormat.getTagFieldNumber(tag);
Expand Down Expand Up @@ -88,7 +87,7 @@ final boolean mergeOneFieldFrom(B unknownFields, Reader reader) throws IOExcepti
}
}

final void mergeFrom(B unknownFields, Reader reader) throws IOException {
private final void mergeFrom(B unknownFields, Reader reader) throws IOException {
while (true) {
if (reader.getFieldNumber() == Reader.READ_DONE
|| !mergeOneFieldFrom(unknownFields, reader)) {
Expand Down
3 changes: 3 additions & 0 deletions java/lite/src/test/java/com/google/protobuf/LiteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static java.util.Collections.singletonList;
import static org.junit.Assert.assertThrows;

import com.google.protobuf.FieldPresenceTestProto.TestAllTypes;
import com.google.protobuf.UnittestImportLite.ImportEnumLite;
import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite;
import com.google.protobuf.UnittestLite.ForeignEnumLite;
import com.google.protobuf.UnittestLite.ForeignMessageLite;
import com.google.protobuf.UnittestLite.RecursiveGroup;
import com.google.protobuf.UnittestLite.RecursiveMessage;
import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite;
Expand Down Expand Up @@ -51,6 +53,7 @@
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
4 changes: 4 additions & 0 deletions src/google/protobuf/unittest_lite.proto
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,7 @@ message RecursiveMessage {
optional RecursiveMessage recurse = 1;
optional bytes payload = 2;
}

message RecursiveGroup {
RecursiveGroup recurse = 1 [features.message_encoding = DELIMITED];
}

0 comments on commit 850fcce

Please sign in to comment.