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

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: Make chrome settings proto generated file a component Created 4 years 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..e6358c3bae341d286ac29376e4bd42fb03d53ab0 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
@@ -297,7 +297,7 @@ public final class DynamicMessage extends AbstractMessage {
} catch (InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(builder.buildPartial());
} catch (IOException e) {
- throw new InvalidProtocolBufferException(e.getMessage())
+ throw new InvalidProtocolBufferException(e)
.setUnfinishedMessage(builder.buildPartial());
}
return builder.buildPartial();
@@ -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