Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
diff --git a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
index 859a9e8fc512e55c138c5a2939bd5edd40bd9743..c54da67fbb5ac06c56db3c7833bc493a5a12a73f 100644
--- a/third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
+++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/DynamicMessage.java
@@ -526,6 +526,14 @@ public final class DynamicMessage extends AbstractMessage {
fields.clearField(oldField);
}
oneofCases[index] = field;
+ } else if (field.getFile().getSyntax() == Descriptors.FileDescriptor.Syntax.PROTO3) {
+ if (!field.isRepeated()
+ && field.getJavaType() != FieldDescriptor.JavaType.MESSAGE
+ && value.equals(field.getDefaultValue())) {
+ // In proto3, setting a field to its default value is equivalent to clearing the field.
+ fields.clearField(field);
+ return this;
+ }
}
fields.setField(field, value);
return this;

Powered by Google App Engine
This is Rietveld 408576698