|
|
|
@ -535,11 +535,10 @@ 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.
|
|
|
|
|
} else if (!field.hasPresence()) { |
|
|
|
|
if (!field.isRepeated() && value.equals(field.getDefaultValue())) { |
|
|
|
|
// Setting a field without presence to its default value is equivalent to clearing the
|
|
|
|
|
// field.
|
|
|
|
|
fields.clearField(field); |
|
|
|
|
return this; |
|
|
|
|
} |
|
|
|
|