gRPC migration
Change-Id: Ib390f6dde0d5a8d6db12ccd7da41135570ad1354
diff --git a/vendor/github.com/golang/protobuf/jsonpb/decode.go b/vendor/github.com/golang/protobuf/jsonpb/decode.go
index 7c6c5a5..60e82ca 100644
--- a/vendor/github.com/golang/protobuf/jsonpb/decode.go
+++ b/vendor/github.com/golang/protobuf/jsonpb/decode.go
@@ -135,14 +135,14 @@
md := m.Descriptor()
fds := md.Fields()
- if string(in) == "null" && md.FullName() != "google.protobuf.Value" {
- return nil
- }
-
if jsu, ok := proto.MessageV1(m.Interface()).(JSONPBUnmarshaler); ok {
return jsu.UnmarshalJSONPB(u, in)
}
+ if string(in) == "null" && md.FullName() != "google.protobuf.Value" {
+ return nil
+ }
+
switch wellKnownType(md.FullName()) {
case "Any":
var jsonObject map[string]json.RawMessage
@@ -332,11 +332,12 @@
raw = v
}
+ field := m.NewField(fd)
// Unmarshal the field value.
- if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd)) {
+ if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
continue
}
- v, err := u.unmarshalValue(m.NewField(fd), raw, fd)
+ v, err := u.unmarshalValue(field, raw, fd)
if err != nil {
return err
}
@@ -364,11 +365,12 @@
return fmt.Errorf("extension field %q does not extend message %q", xname, m.Descriptor().FullName())
}
+ field := m.NewField(fd)
// Unmarshal the field value.
- if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd)) {
+ if raw == nil || (string(raw) == "null" && !isSingularWellKnownValue(fd) && !isSingularJSONPBUnmarshaler(field, fd)) {
continue
}
- v, err := u.unmarshalValue(m.NewField(fd), raw, fd)
+ v, err := u.unmarshalValue(field, raw, fd)
if err != nil {
return err
}
@@ -390,6 +392,14 @@
return false
}
+func isSingularJSONPBUnmarshaler(v protoreflect.Value, fd protoreflect.FieldDescriptor) bool {
+ if fd.Message() != nil && fd.Cardinality() != protoreflect.Repeated {
+ _, ok := proto.MessageV1(v.Interface()).(JSONPBUnmarshaler)
+ return ok
+ }
+ return false
+}
+
func (u *Unmarshaler) unmarshalValue(v protoreflect.Value, in []byte, fd protoreflect.FieldDescriptor) (protoreflect.Value, error) {
switch {
case fd.IsList():