Skip to content

Commit

Permalink
Merge pull request #10005 from dlj-NaN/sync-stage
Browse files Browse the repository at this point in the history
Integrate from Piper for C++, Java, and Python
  • Loading branch information
dlj-NaN authored May 20, 2022
2 parents cd5cc37 + 42ff77e commit 450d24c
Show file tree
Hide file tree
Showing 61 changed files with 933 additions and 463 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Java
* Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
* 6x speedup in ArrayEncoder.writeUInt32NotTag
* Java generated code is no longer compatible with runtimes 2.6.1 and earlier

Python
* Increment python major version to 4 in version.json for python upb (#9926)
Expand All @@ -26,6 +27,7 @@
* Due to the breaking changes for Python, the major version number for Python
has been incremented.
* The binary wheel for macOS now supports Apple silicon.
* In TextFormat, transform UnicodeDecodeError into ParseError.


PHP
Expand Down
Binary file modified csharp/src/Google.Protobuf.Test/testprotos.pb
Binary file not shown.
7 changes: 2 additions & 5 deletions csharp/src/Google.Protobuf/Reflection/Descriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7098,11 +7098,8 @@ public void ClearJstype() {
/// check its required fields, regardless of whether or not the message has
/// been parsed.
///
/// As of 2021, lazy does no correctness checks on the byte stream during
/// parsing. This may lead to crashes if and when an invalid byte stream is
/// finally parsed upon access.
///
/// TODO(b/211906113): Enable validation on lazy fields.
/// As of May 2022, lazy verifies the contents of the byte stream during
/// parsing. An invalid byte stream will cause the overall parsing to fail.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand Down
9 changes: 4 additions & 5 deletions java/core/src/main/java/com/google/protobuf/Descriptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,20 @@ public static FileDescriptor internalBuildGeneratedFileFrom(
}

/**
* This method is to be called by generated code only. It is used to update the
* This method is to be called by generated code only. It updates the
* FileDescriptorProto associated with the descriptor by parsing it again with the given
* ExtensionRegistry. This is needed to recognize custom options.
*/
public static void internalUpdateFileDescriptor(
final FileDescriptor descriptor, final ExtensionRegistry registry) {
FileDescriptor descriptor, ExtensionRegistry registry) {
ByteString bytes = descriptor.proto.toByteString();
FileDescriptorProto proto;
try {
proto = FileDescriptorProto.parseFrom(bytes, registry);
FileDescriptorProto proto = FileDescriptorProto.parseFrom(bytes, registry);
descriptor.setProto(proto);
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException(
"Failed to parse protocol buffer descriptor for generated code.", e);
}
descriptor.setProto(proto);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,16 @@ public static enum MethodToInvoke {
*
* <p>For use by generated code only.
*/
protected abstract Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1);
protected abstract Object dynamicMethod(
MethodToInvoke method,
Object arg0,
Object arg1);

/** Same as {@link #dynamicMethod(MethodToInvoke, Object, Object)} with {@code null} padding. */
@CanIgnoreReturnValue
protected Object dynamicMethod(MethodToInvoke method, Object arg0) {
protected Object dynamicMethod(
MethodToInvoke method,
Object arg0) {
return dynamicMethod(method, arg0, null);
}

Expand Down Expand Up @@ -1245,11 +1250,11 @@ public MessageLite getMessageDefaultInstance() {
}

@SuppressWarnings("unchecked")
Object fromFieldSetType(final Object value) {
Object fromFieldSetType(Object value) {
if (descriptor.isRepeated()) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
final List result = new ArrayList<>();
for (final Object element : (List) value) {
List<Object> result = new ArrayList<>();
for (Object element : (List) value) {
result.add(singularFromFieldSetType(element));
}
return result;
Expand All @@ -1261,20 +1266,19 @@ Object fromFieldSetType(final Object value) {
}
}

Object singularFromFieldSetType(final Object value) {
Object singularFromFieldSetType(Object value) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
return descriptor.enumTypeMap.findValueByNumber((Integer) value);
} else {
return value;
}
}

@SuppressWarnings("unchecked")
Object toFieldSetType(final Object value) {
Object toFieldSetType(Object value) {
if (descriptor.isRepeated()) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
final List result = new ArrayList<>();
for (final Object element : (List) value) {
List<Object> result = new ArrayList<>();
for (Object element : (List) value) {
result.add(singularToFieldSetType(element));
}
return result;
Expand All @@ -1286,7 +1290,7 @@ Object toFieldSetType(final Object value) {
}
}

Object singularToFieldSetType(final Object value) {
Object singularToFieldSetType(Object value) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
return ((Internal.EnumLite) value).getNumber();
} else {
Expand Down
Loading

0 comments on commit 450d24c

Please sign in to comment.