Sync from Piper @mkruskal/footmitten

PROTOBUF_SYNC_PIPER
pull/10729/head
Mike Kruskal 2 years ago
parent 388e3d744f
commit a7da44c5ae
  1. 2
      examples/README.md
  2. 28
      java/core/src/main/java/com/google/protobuf/ExtensionSchemaLite.java
  3. 5
      java/core/src/main/java/com/google/protobuf/FieldSet.java
  4. 2
      third_party/googletest

@ -28,7 +28,7 @@ Then you can run the built binary:
$ bazel-bin/add_person_cpp addressbook.data $ bazel-bin/add_person_cpp addressbook.data
To use protobuf in your own bazel project, please follow instructions in the To use protobuf in your own bazel project, please follow instructions in the
[BUILD](BUILD) file and [WORKSPACE](WORKSPACE) file. [BUILD.bazel](BUILD.bazel) file and [WORKSPACE](WORKSPACE) file.
## Build the example using make ## Build the example using make

@ -255,12 +255,40 @@ final class ExtensionSchemaLite extends ExtensionSchema<ExtensionDescriptor> {
value = reader.readString(); value = reader.readString();
break; break;
case GROUP: case GROUP:
if (!extension.isRepeated()) {
Object oldValue = extensions.getField(extension.descriptor);
if (oldValue instanceof GeneratedMessageLite) {
Schema extSchema = Protobuf.getInstance().schemaFor(oldValue);
if (!((GeneratedMessageLite<?, ?>) oldValue).isMutable()) {
Object newValue = extSchema.newInstance();
extSchema.mergeFrom(newValue, oldValue);
extensions.setField(extension.descriptor, newValue);
oldValue = newValue;
}
reader.mergeGroupField(oldValue, extSchema, extensionRegistry);
return unknownFields;
}
}
value = value =
reader.readGroup( reader.readGroup(
extension.getMessageDefaultInstance().getClass(), extensionRegistry); extension.getMessageDefaultInstance().getClass(), extensionRegistry);
break; break;
case MESSAGE: case MESSAGE:
if (!extension.isRepeated()) {
Object oldValue = extensions.getField(extension.descriptor);
if (oldValue instanceof GeneratedMessageLite) {
Schema extSchema = Protobuf.getInstance().schemaFor(oldValue);
if (!((GeneratedMessageLite<?, ?>) oldValue).isMutable()) {
Object newValue = extSchema.newInstance();
extSchema.mergeFrom(newValue, oldValue);
extensions.setField(extension.descriptor, newValue);
oldValue = newValue;
}
reader.mergeMessageField(oldValue, extSchema, extensionRegistry);
return unknownFields;
}
}
value = value =
reader.readMessage( reader.readMessage(
extension.getMessageDefaultInstance().getClass(), extensionRegistry); extension.getMessageDefaultInstance().getClass(), extensionRegistry);

@ -123,6 +123,11 @@ final class FieldSet<T extends FieldSet.FieldDescriptorLite<T>> {
if (isImmutable) { if (isImmutable) {
return; return;
} }
for (Object value : fields.values()) {
if (value instanceof GeneratedMessageLite) {
((GeneratedMessageLite<?, ?>) value).makeImmutable();
}
}
fields.makeImmutable(); fields.makeImmutable();
isImmutable = true; isImmutable = true;
} }

@ -1 +1 @@
Subproject commit 4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774 Subproject commit 5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081
Loading…
Cancel
Save