Fix logic to decouple from the order of fields.keySet

This commit is contained in:
Jason Lunn 2021-10-04 13:57:47 +00:00
parent 3581d85ced
commit a09c8e1c79

View File

@ -674,9 +674,9 @@ public class RubyMessage extends RubyObject {
boolean isDefaultStringForBytes = false;
FieldDescriptor enumFieldDescriptorForType =
this.builder.getDescriptorForType().findFieldByName("type");
EnumValueDescriptor type = enumFieldDescriptorForType == null ?
null : ((EnumValueDescriptor)this.builder.getField(enumFieldDescriptorForType));
if (type != null && type.getName().equals("TYPE_BYTES") &&
String type = enumFieldDescriptorForType == null ?
null : fields.get(enumFieldDescriptorForType).toString();
if (type != null && type.equals("TYPE_BYTES") &&
fieldDescriptor.getFullName().equals("google.protobuf.FieldDescriptorProto.default_value")) {
isDefaultStringForBytes = true;
}