Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
Fix handling for the case where a field is an unset oneof
Browse files Browse the repository at this point in the history
  • Loading branch information
makearl committed Feb 9, 2018
1 parent 8377443 commit 46d2062
Show file tree
Hide file tree
Showing 4 changed files with 1,010 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.FLOAT;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.INT32;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.INT64;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.MESSAGE;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT32;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.SINT64;
import static com.google.protobuf.Descriptors.FieldDescriptor.Type.STRING;
Expand Down Expand Up @@ -81,7 +82,9 @@ private String getProtoFieldName(String descriptorForTypeName, String connectFie
}

private boolean isUnsetOneof(Descriptors.FieldDescriptor fieldDescriptor, Object value) {
return fieldDescriptor.getContainingOneof() != null && fieldDescriptor.getDefaultValue() == value;
return fieldDescriptor.getContainingOneof() != null &&
fieldDescriptor.getType() != MESSAGE &&
fieldDescriptor.getDefaultValue().equals(value);
}

ProtobufData(Class<? extends com.google.protobuf.GeneratedMessageV3> clazz, String legacyName) {
Expand Down
Loading

0 comments on commit 46d2062

Please sign in to comment.