Internal change

PiperOrigin-RevId: 653615736
pull/17348/head
Protobuf Team Bot 4 months ago committed by Copybara-Service
parent 3ff2cf05f3
commit cc8b3483a5
  1. 3
      java/core/src/main/java/com/google/protobuf/ArrayDecoders.java
  2. 2
      java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java
  3. 3
      java/core/src/main/java/com/google/protobuf/MessageSchema.java
  4. 1
      java/core/src/main/java/com/google/protobuf/MessageSetSchema.java
  5. 3
      java/core/src/main/java/com/google/protobuf/UnknownFieldSchema.java
  6. 3
      java/lite/src/test/java/com/google/protobuf/LiteTest.java
  7. 4
      src/google/protobuf/unittest_lite.proto

@ -24,8 +24,7 @@ import java.io.IOException;
@CheckReturnValue @CheckReturnValue
final class ArrayDecoders { final class ArrayDecoders {
private ArrayDecoders() { private ArrayDecoders() {}
}
/** /**
* A helper used to return multiple values in a Java function. Java doesn't natively support * A helper used to return multiple values in a Java function. Java doesn't natively support

@ -132,7 +132,7 @@ public class InvalidProtocolBufferException extends IOException {
static InvalidProtocolBufferException recursionLimitExceeded() { static InvalidProtocolBufferException recursionLimitExceeded() {
return new InvalidProtocolBufferException( return new InvalidProtocolBufferException(
"Protocol message had too many levels of nesting. May be malicious. " "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() { static InvalidProtocolBufferException sizeLimitExceeded() {

@ -3006,6 +3006,7 @@ final class MessageSchema<T> implements Schema<T> {
unknownFields = unknownFieldSchema.getBuilderFromMessage(message); unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
} }
// Unknown field. // Unknown field.
if (unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) { if (unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
continue; continue;
} }
@ -3381,6 +3382,7 @@ final class MessageSchema<T> implements Schema<T> {
if (unknownFields == null) { if (unknownFields == null) {
unknownFields = unknownFieldSchema.getBuilderFromMessage(message); unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
} }
if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) { if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
return; return;
} }
@ -3397,6 +3399,7 @@ final class MessageSchema<T> implements Schema<T> {
if (unknownFields == null) { if (unknownFields == null) {
unknownFields = unknownFieldSchema.getBuilderFromMessage(message); unknownFields = unknownFieldSchema.getBuilderFromMessage(message);
} }
if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) { if (!unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader)) {
return; return;
} }

@ -278,6 +278,7 @@ final class MessageSetSchema<T> implements Schema<T> {
reader, extension, extensionRegistry, extensions); reader, extension, extensionRegistry, extensions);
return true; return true;
} else { } else {
return unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader); return unknownFieldSchema.mergeOneFieldFrom(unknownFields, reader);
} }
} else { } else {

@ -55,7 +55,6 @@ abstract class UnknownFieldSchema<T, B> {
/** Marks unknown fields as immutable. */ /** Marks unknown fields as immutable. */
abstract void makeImmutable(Object message); abstract void makeImmutable(Object message);
/** Merges one field into the unknown fields. */
final boolean mergeOneFieldFrom(B unknownFields, Reader reader) throws IOException { final boolean mergeOneFieldFrom(B unknownFields, Reader reader) throws IOException {
int tag = reader.getTag(); int tag = reader.getTag();
int fieldNumber = WireFormat.getTagFieldNumber(tag); int fieldNumber = WireFormat.getTagFieldNumber(tag);
@ -88,7 +87,7 @@ abstract class UnknownFieldSchema<T, B> {
} }
} }
final void mergeFrom(B unknownFields, Reader reader) throws IOException { private final void mergeFrom(B unknownFields, Reader reader) throws IOException {
while (true) { while (true) {
if (reader.getFieldNumber() == Reader.READ_DONE if (reader.getFieldNumber() == Reader.READ_DONE
|| !mergeOneFieldFrom(unknownFields, reader)) { || !mergeOneFieldFrom(unknownFields, reader)) {

@ -10,12 +10,14 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assertWithMessage;
import static java.util.Collections.singletonList; import static java.util.Collections.singletonList;
import static org.junit.Assert.assertThrows;
import com.google.protobuf.FieldPresenceTestProto.TestAllTypes; import com.google.protobuf.FieldPresenceTestProto.TestAllTypes;
import com.google.protobuf.UnittestImportLite.ImportEnumLite; import com.google.protobuf.UnittestImportLite.ImportEnumLite;
import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite; import com.google.protobuf.UnittestImportPublicLite.PublicImportMessageLite;
import com.google.protobuf.UnittestLite.ForeignEnumLite; import com.google.protobuf.UnittestLite.ForeignEnumLite;
import com.google.protobuf.UnittestLite.ForeignMessageLite; import com.google.protobuf.UnittestLite.ForeignMessageLite;
import com.google.protobuf.UnittestLite.RecursiveGroup;
import com.google.protobuf.UnittestLite.RecursiveMessage; import com.google.protobuf.UnittestLite.RecursiveMessage;
import com.google.protobuf.UnittestLite.TestAllExtensionsLite; import com.google.protobuf.UnittestLite.TestAllExtensionsLite;
import com.google.protobuf.UnittestLite.TestAllTypesLite; import com.google.protobuf.UnittestLite.TestAllTypesLite;
@ -50,6 +52,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;

@ -625,3 +625,7 @@ message RecursiveMessage {
RecursiveMessage recurse = 1; RecursiveMessage recurse = 1;
bytes payload = 2; bytes payload = 2;
} }
message RecursiveGroup {
RecursiveGroup recurse = 1 [features.message_encoding = DELIMITED];
}

Loading…
Cancel
Save