[VOL-5486] Upgrade library versions
Change-Id: I8b4e88699e03f44ee13e467867f45ae3f0a63c4b
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/binary.go b/vendor/github.com/jhump/protoreflect/dynamic/binary.go
index 91fd672..39e077a 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/binary.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/binary.go
@@ -4,9 +4,11 @@
import (
"fmt"
- "github.com/golang/protobuf/proto"
- "github.com/jhump/protoreflect/codec"
"io"
+
+ "github.com/golang/protobuf/proto"
+
+ "github.com/jhump/protoreflect/codec"
)
// defaultDeterminism, if true, will mean that calls to Marshal will produce
@@ -71,6 +73,9 @@
}
func (m *Message) marshal(b *codec.Buffer) error {
+ if m.GetMessageDescriptor().GetMessageOptions().GetMessageSetWireFormat() {
+ return fmt.Errorf("%s is a message set; marshaling message sets is not implemented", m.GetMessageDescriptor().GetFullyQualifiedName())
+ }
if err := m.marshalKnownFields(b); err != nil {
return err
}
@@ -150,6 +155,9 @@
}
func (m *Message) unmarshal(buf *codec.Buffer, isGroup bool) error {
+ if m.GetMessageDescriptor().GetMessageOptions().GetMessageSetWireFormat() {
+ return fmt.Errorf("%s is a message set; unmarshaling message sets is not implemented", m.GetMessageDescriptor().GetFullyQualifiedName())
+ }
for !buf.EOF() {
fd, val, err := buf.DecodeFieldValue(m.FindFieldDescriptor, m.mf)
if err != nil {
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/doc.go b/vendor/github.com/jhump/protoreflect/dynamic/doc.go
index c329fcd..59b77eb 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/doc.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/doc.go
@@ -15,8 +15,7 @@
// will be used to create other messages or parse extension fields during
// de-serialization.
//
-//
-// Field Types
+// # Field Types
//
// The types of values expected by setters and returned by getters are the
// same as protoc generates for scalar fields. For repeated fields, there are
@@ -72,8 +71,7 @@
// but if the factory is configured with a KnownTypeRegistry, or if the field's
// type is a well-known type, it will return a zero value generated message.
//
-//
-// Unrecognized Fields
+// # Unrecognized Fields
//
// Unrecognized fields are preserved by the dynamic message when unmarshaling
// from the standard binary format. If the message's MessageFactory was
@@ -89,21 +87,20 @@
// it can even happen for non-extension fields! Here's an example scenario where
// a non-extension field can initially be unknown and become known:
//
-// 1. A dynamic message is created with a descriptor, A, and then
-// de-serialized from a stream of bytes. The stream includes an
-// unrecognized tag T. The message will include tag T in its unrecognized
-// field set.
-// 2. Another call site retrieves a newer descriptor, A', which includes a
-// newly added field with tag T.
-// 3. That other call site then uses a FieldDescriptor to access the value of
-// the new field. This will cause the dynamic message to parse the bytes
-// for the unknown tag T and store them as a known field.
-// 4. Subsequent operations for tag T, including setting the field using only
-// tag number or de-serializing a stream that includes tag T, will operate
-// as if that tag were part of the original descriptor, A.
+// 1. A dynamic message is created with a descriptor, A, and then
+// de-serialized from a stream of bytes. The stream includes an
+// unrecognized tag T. The message will include tag T in its unrecognized
+// field set.
+// 2. Another call site retrieves a newer descriptor, A', which includes a
+// newly added field with tag T.
+// 3. That other call site then uses a FieldDescriptor to access the value of
+// the new field. This will cause the dynamic message to parse the bytes
+// for the unknown tag T and store them as a known field.
+// 4. Subsequent operations for tag T, including setting the field using only
+// tag number or de-serializing a stream that includes tag T, will operate
+// as if that tag were part of the original descriptor, A.
//
-//
-// Compatibility
+// # Compatibility
//
// In addition to implementing the proto.Message interface, the included
// Message type also provides an XXX_MessageName() method, so it can work with
@@ -145,8 +142,7 @@
// about fields that the dynamic message does not, these unrecognized fields may
// become known fields in the generated message.
//
-//
-// Registries
+// # Registries
//
// This package also contains a couple of registries, for managing known types
// and descriptors.
@@ -160,4 +156,12 @@
//
// The ExtensionRegistry allows for recognizing and parsing extensions fields
// (for proto2 messages).
+//
+// Deprecated: This module was created for use with the older "v1" Protobuf API
+// in github.com/golang/protobuf. However, much of this module is no longer
+// necessary as the newer "v2" API in google.golang.org/protobuf provides similar
+// capabilities. Instead of using this github.com/jhump/protoreflect/dynamic package,
+// see [google.golang.org/protobuf/types/dynamicpb].
+//
+// [google.golang.org/protobuf/types/dynamicpb]: https://pkg.go.dev/google.golang.org/protobuf/types/dynamicpb
package dynamic
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go b/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go
index de13b92..ff136b0 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/dynamic_message.go
@@ -10,7 +10,9 @@
"strings"
"github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ protov2 "google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/reflect/protoreflect"
+ "google.golang.org/protobuf/types/descriptorpb"
"github.com/jhump/protoreflect/codec"
"github.com/jhump/protoreflect/desc"
@@ -411,19 +413,20 @@
// The Go type of the returned value, for scalar fields, is the same as protoc
// would generate for the field (in a non-dynamic message). The table below
// lists the scalar types and the corresponding Go types.
-// +-------------------------+-----------+
-// | Declared Type | Go Type |
-// +-------------------------+-----------+
-// | int32, sint32, sfixed32 | int32 |
-// | int64, sint64, sfixed64 | int64 |
-// | uint32, fixed32 | uint32 |
-// | uint64, fixed64 | uint64 |
-// | float | float32 |
-// | double | double32 |
-// | bool | bool |
-// | string | string |
-// | bytes | []byte |
-// +-------------------------+-----------+
+//
+// +-------------------------+-----------+
+// | Declared Type | Go Type |
+// +-------------------------+-----------+
+// | int32, sint32, sfixed32 | int32 |
+// | int64, sint64, sfixed64 | int64 |
+// | uint32, fixed32 | uint32 |
+// | uint64, fixed64 | uint64 |
+// | float | float32 |
+// | double | double32 |
+// | bool | bool |
+// | string | string |
+// | bytes | []byte |
+// +-------------------------+-----------+
//
// Values for enum fields will always be int32 values. You can use the enum
// descriptor associated with the field to lookup value names with those values.
@@ -1883,42 +1886,42 @@
}
switch t {
- case descriptor.FieldDescriptorProto_TYPE_SFIXED32,
- descriptor.FieldDescriptorProto_TYPE_INT32,
- descriptor.FieldDescriptorProto_TYPE_SINT32,
- descriptor.FieldDescriptorProto_TYPE_ENUM:
+ case descriptorpb.FieldDescriptorProto_TYPE_SFIXED32,
+ descriptorpb.FieldDescriptorProto_TYPE_INT32,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT32,
+ descriptorpb.FieldDescriptorProto_TYPE_ENUM:
return toInt32(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_SFIXED64,
- descriptor.FieldDescriptorProto_TYPE_INT64,
- descriptor.FieldDescriptorProto_TYPE_SINT64:
+ case descriptorpb.FieldDescriptorProto_TYPE_SFIXED64,
+ descriptorpb.FieldDescriptorProto_TYPE_INT64,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT64:
return toInt64(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_FIXED32,
- descriptor.FieldDescriptorProto_TYPE_UINT32:
+ case descriptorpb.FieldDescriptorProto_TYPE_FIXED32,
+ descriptorpb.FieldDescriptorProto_TYPE_UINT32:
return toUint32(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_FIXED64,
- descriptor.FieldDescriptorProto_TYPE_UINT64:
+ case descriptorpb.FieldDescriptorProto_TYPE_FIXED64,
+ descriptorpb.FieldDescriptorProto_TYPE_UINT64:
return toUint64(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_FLOAT:
+ case descriptorpb.FieldDescriptorProto_TYPE_FLOAT:
return toFloat32(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
+ case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE:
return toFloat64(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_BOOL:
+ case descriptorpb.FieldDescriptorProto_TYPE_BOOL:
return toBool(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_BYTES:
+ case descriptorpb.FieldDescriptorProto_TYPE_BYTES:
return toBytes(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_STRING:
+ case descriptorpb.FieldDescriptorProto_TYPE_STRING:
return toString(reflect.Indirect(val), fd)
- case descriptor.FieldDescriptorProto_TYPE_MESSAGE,
- descriptor.FieldDescriptorProto_TYPE_GROUP:
+ case descriptorpb.FieldDescriptorProto_TYPE_MESSAGE,
+ descriptorpb.FieldDescriptorProto_TYPE_GROUP:
m, err := asMessage(val, fd.GetFullyQualifiedName())
// check that message is correct type
if err != nil {
@@ -2053,8 +2056,9 @@
// ConvertTo converts this dynamic message into the given message. This is
// shorthand for resetting then merging:
-// target.Reset()
-// m.MergeInto(target)
+//
+// target.Reset()
+// m.MergeInto(target)
func (m *Message) ConvertTo(target proto.Message) error {
if err := m.checkType(target); err != nil {
return err
@@ -2081,8 +2085,9 @@
// ConvertFrom converts the given message into this dynamic message. This is
// shorthand for resetting then merging:
-// m.Reset()
-// m.MergeFrom(target)
+//
+// m.Reset()
+// m.MergeFrom(target)
func (m *Message) ConvertFrom(target proto.Message) error {
if err := m.checkType(target); err != nil {
return err
@@ -2553,6 +2558,66 @@
}
}
+ // With API v2, it is possible that the new protoreflect interfaces
+ // were used to store an extension, which means it can't be returned
+ // by proto.ExtensionDescs and it's also not in the unrecognized data.
+ // So we have a separate loop to trawl through it...
+ var err error
+ proto.MessageReflect(pm).Range(func(fld protoreflect.FieldDescriptor, val protoreflect.Value) bool {
+ if !fld.IsExtension() {
+ // normal field... we already got it above
+ return true
+ }
+ xt := fld.(protoreflect.ExtensionTypeDescriptor)
+ if _, ok := xt.Type().(*proto.ExtensionDesc); ok {
+ // known extension... we already got it above
+ return true
+ }
+ var fd *desc.FieldDescriptor
+ fd, err = desc.WrapField(fld)
+ if err != nil {
+ return false
+ }
+ v := convertProtoReflectValue(val)
+ if v, err = validFieldValue(fd, v); err != nil {
+ return false
+ }
+ values[fd] = v
+ return true
+ })
+ if err != nil {
+ return err
+ }
+
+ // unrecognized extensions fields:
+ // In API v2 of proto, some extensions may NEITHER be included in ExtensionDescs
+ // above NOR included in unrecognized fields below. These are extensions that use
+ // a custom extension type (not a generated one -- i.e. not a linked in extension).
+ mr := proto.MessageReflect(pm)
+ var extBytes []byte
+ var retErr error
+ mr.Range(func(fld protoreflect.FieldDescriptor, val protoreflect.Value) bool {
+ if !fld.IsExtension() {
+ // normal field, already processed above
+ return true
+ }
+ if extd, ok := fld.(protoreflect.ExtensionTypeDescriptor); ok {
+ if _, ok := extd.Type().(*proto.ExtensionDesc); ok {
+ // normal known extension, already processed above
+ return true
+ }
+ }
+
+ // marshal the extension to bytes and then handle as unknown field below
+ mr.New()
+ mr.Set(fld, val)
+ extBytes, retErr = protov2.MarshalOptions{}.MarshalAppend(extBytes, mr.Interface())
+ return retErr == nil
+ })
+ if retErr != nil {
+ return retErr
+ }
+
// now actually perform the merge
for fd, v := range values {
if err := mergeField(m, fd, v); err != nil {
@@ -2560,6 +2625,12 @@
}
}
+ if len(extBytes) > 0 {
+ // treating unrecognized extensions like unknown fields: best-effort
+ // ignore any error returned: pulling in unknown fields is best-effort
+ _ = m.UnmarshalMerge(extBytes)
+ }
+
data := internal.GetUnrecognized(pm)
if len(data) > 0 {
// ignore any error returned: pulling in unknown fields is best-effort
@@ -2569,6 +2640,31 @@
return nil
}
+func convertProtoReflectValue(v protoreflect.Value) interface{} {
+ val := v.Interface()
+ switch val := val.(type) {
+ case protoreflect.Message:
+ return val.Interface()
+ case protoreflect.Map:
+ mp := make(map[interface{}]interface{}, val.Len())
+ val.Range(func(k protoreflect.MapKey, v protoreflect.Value) bool {
+ mp[convertProtoReflectValue(k.Value())] = convertProtoReflectValue(v)
+ return true
+ })
+ return mp
+ case protoreflect.List:
+ sl := make([]interface{}, val.Len())
+ for i := 0; i < val.Len(); i++ {
+ sl[i] = convertProtoReflectValue(val.Get(i))
+ }
+ return sl
+ case protoreflect.EnumNumber:
+ return int32(val)
+ default:
+ return val
+ }
+}
+
// Validate checks that all required fields are present. It returns an error if any are absent.
func (m *Message) Validate() error {
missingFields := m.findMissingFields()
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/grpcdynamic/stub.go b/vendor/github.com/jhump/protoreflect/dynamic/grpcdynamic/stub.go
index 1eaedfa..6fca393 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/grpcdynamic/stub.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/grpcdynamic/stub.go
@@ -4,11 +4,11 @@
package grpcdynamic
import (
+ "context"
"fmt"
"io"
"github.com/golang/protobuf/proto"
- "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
@@ -27,12 +27,7 @@
// type used to construct Stubs. But the use of this interface allows
// construction of stubs that use alternate concrete types as the transport for
// RPC operations.
-type Channel interface {
- Invoke(ctx context.Context, method string, args, reply interface{}, opts ...grpc.CallOption) error
- NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
-}
-
-var _ Channel = (*grpc.ClientConn)(nil)
+type Channel = grpc.ClientConnInterface
// NewStub creates a new RPC stub that uses the given channel for dispatching RPCs.
func NewStub(channel Channel) Stub {
@@ -79,6 +74,7 @@
ClientStreams: method.IsClientStreaming(),
}
if cs, err := s.channel.NewStream(ctx, &sd, requestMethod(method), opts...); err != nil {
+ cancel()
return nil, err
} else {
err = cs.SendMsg(request)
@@ -91,6 +87,11 @@
cancel()
return nil, err
}
+ go func() {
+ // when the new stream is finished, also cleanup the parent context
+ <-cs.Context().Done()
+ cancel()
+ }()
return &ServerStream{cs, method.GetOutputType(), s.mf}, nil
}
}
@@ -108,8 +109,14 @@
ClientStreams: method.IsClientStreaming(),
}
if cs, err := s.channel.NewStream(ctx, &sd, requestMethod(method), opts...); err != nil {
+ cancel()
return nil, err
} else {
+ go func() {
+ // when the new stream is finished, also cleanup the parent context
+ <-cs.Context().Done()
+ cancel()
+ }()
return &ClientStream{cs, method, s.mf, cancel}, nil
}
}
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/json.go b/vendor/github.com/jhump/protoreflect/dynamic/json.go
index 02c8298..9081965 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/json.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/json.go
@@ -17,14 +17,14 @@
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ "google.golang.org/protobuf/types/descriptorpb"
// link in the well-known-types that have a special JSON format
- _ "github.com/golang/protobuf/ptypes/any"
- _ "github.com/golang/protobuf/ptypes/duration"
- _ "github.com/golang/protobuf/ptypes/empty"
- _ "github.com/golang/protobuf/ptypes/struct"
- _ "github.com/golang/protobuf/ptypes/timestamp"
- _ "github.com/golang/protobuf/ptypes/wrappers"
+ _ "google.golang.org/protobuf/types/known/anypb"
+ _ "google.golang.org/protobuf/types/known/durationpb"
+ _ "google.golang.org/protobuf/types/known/emptypb"
+ _ "google.golang.org/protobuf/types/known/structpb"
+ _ "google.golang.org/protobuf/types/known/timestamppb"
+ _ "google.golang.org/protobuf/types/known/wrapperspb"
"github.com/jhump/protoreflect/desc"
)
@@ -60,7 +60,7 @@
// This method is convenient shorthand for invoking MarshalJSONPB with a default
// (zero value) marshaler:
//
-// m.MarshalJSONPB(&jsonpb.Marshaler{})
+// m.MarshalJSONPB(&jsonpb.Marshaler{})
//
// So enums are serialized using enum value name strings, and values that are
// not present (including those with default/zero value for messages defined in
@@ -80,7 +80,7 @@
// This method is convenient shorthand for invoking MarshalJSONPB with a default
// (zero value) marshaler:
//
-// m.MarshalJSONPB(&jsonpb.Marshaler{Indent: " "})
+// m.MarshalJSONPB(&jsonpb.Marshaler{Indent: " "})
//
// So enums are serialized using enum value name strings, and values that are
// not present (including those with default/zero value for messages defined in
@@ -497,7 +497,7 @@
// This method is shorthand for invoking UnmarshalJSONPB with a default (zero
// value) unmarshaler:
//
-// m.UnmarshalMergeJSONPB(&jsonpb.Unmarshaler{}, js)
+// m.UnmarshalMergeJSONPB(&jsonpb.Unmarshaler{}, js)
//
// So unknown fields will result in an error, and no provided jsonpb.AnyResolver
// will be used when parsing google.protobuf.Any messages.
@@ -669,13 +669,13 @@
}
func isWellKnownValue(fd *desc.FieldDescriptor) bool {
- return !fd.IsRepeated() && fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE &&
+ return !fd.IsRepeated() && fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE &&
fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.Value"
}
func isWellKnownListValue(fd *desc.FieldDescriptor) bool {
// we look for ListValue; but we also look for Value, which can be assigned a ListValue
- return !fd.IsRepeated() && fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE &&
+ return !fd.IsRepeated() && fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE &&
(fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.ListValue" ||
fd.GetMessageType().GetFullyQualifiedName() == "google.protobuf.Value")
}
@@ -794,8 +794,8 @@
}
switch fd.GetType() {
- case descriptor.FieldDescriptorProto_TYPE_MESSAGE,
- descriptor.FieldDescriptorProto_TYPE_GROUP:
+ case descriptorpb.FieldDescriptorProto_TYPE_MESSAGE,
+ descriptorpb.FieldDescriptorProto_TYPE_GROUP:
if t == nil && allowNilMessage {
// if json is simply "null" return a nil pointer
@@ -822,7 +822,7 @@
}
return m, nil
- case descriptor.FieldDescriptorProto_TYPE_ENUM:
+ case descriptorpb.FieldDescriptorProto_TYPE_ENUM:
if e, err := r.nextNumber(); err != nil {
return nil, err
} else {
@@ -842,9 +842,9 @@
}
}
- case descriptor.FieldDescriptorProto_TYPE_INT32,
- descriptor.FieldDescriptorProto_TYPE_SINT32,
- descriptor.FieldDescriptorProto_TYPE_SFIXED32:
+ case descriptorpb.FieldDescriptorProto_TYPE_INT32,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT32,
+ descriptorpb.FieldDescriptorProto_TYPE_SFIXED32:
if i, err := r.nextInt(); err != nil {
return nil, err
} else if i > math.MaxInt32 || i < math.MinInt32 {
@@ -853,13 +853,13 @@
return int32(i), err
}
- case descriptor.FieldDescriptorProto_TYPE_INT64,
- descriptor.FieldDescriptorProto_TYPE_SINT64,
- descriptor.FieldDescriptorProto_TYPE_SFIXED64:
+ case descriptorpb.FieldDescriptorProto_TYPE_INT64,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT64,
+ descriptorpb.FieldDescriptorProto_TYPE_SFIXED64:
return r.nextInt()
- case descriptor.FieldDescriptorProto_TYPE_UINT32,
- descriptor.FieldDescriptorProto_TYPE_FIXED32:
+ case descriptorpb.FieldDescriptorProto_TYPE_UINT32,
+ descriptorpb.FieldDescriptorProto_TYPE_FIXED32:
if i, err := r.nextUint(); err != nil {
return nil, err
} else if i > math.MaxUint32 {
@@ -868,11 +868,11 @@
return uint32(i), err
}
- case descriptor.FieldDescriptorProto_TYPE_UINT64,
- descriptor.FieldDescriptorProto_TYPE_FIXED64:
+ case descriptorpb.FieldDescriptorProto_TYPE_UINT64,
+ descriptorpb.FieldDescriptorProto_TYPE_FIXED64:
return r.nextUint()
- case descriptor.FieldDescriptorProto_TYPE_BOOL:
+ case descriptorpb.FieldDescriptorProto_TYPE_BOOL:
if str, ok := t.(string); ok {
if str == "true" {
r.poll() // consume token
@@ -884,20 +884,20 @@
}
return r.nextBool()
- case descriptor.FieldDescriptorProto_TYPE_FLOAT:
+ case descriptorpb.FieldDescriptorProto_TYPE_FLOAT:
if f, err := r.nextFloat(); err != nil {
return nil, err
} else {
return float32(f), nil
}
- case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
+ case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE:
return r.nextFloat()
- case descriptor.FieldDescriptorProto_TYPE_BYTES:
+ case descriptorpb.FieldDescriptorProto_TYPE_BYTES:
return r.nextBytes()
- case descriptor.FieldDescriptorProto_TYPE_STRING:
+ case descriptorpb.FieldDescriptorProto_TYPE_STRING:
return r.nextString()
default:
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go
index 03162a4..69969fc 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.11.go
@@ -4,8 +4,9 @@
package dynamic
import (
- "github.com/jhump/protoreflect/desc"
"reflect"
+
+ "github.com/jhump/protoreflect/desc"
)
// Pre-Go-1.12, we must use reflect.Value.MapKeys to reflectively
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go
index ef1b370..fb353cf 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/maps_1.12.go
@@ -4,8 +4,9 @@
package dynamic
import (
- "github.com/jhump/protoreflect/desc"
"reflect"
+
+ "github.com/jhump/protoreflect/desc"
)
// With Go 1.12 and above, we can use reflect.Value.MapRange to iterate
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go b/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go
index 9ab8e61..683e7b3 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/message_factory.go
@@ -37,9 +37,10 @@
// (those for which protoc-generated code is statically linked into the Go program) are
// known types. If any dynamic messages are produced, they will recognize and parse all
// "default" extension fields. This is the equivalent of:
-// NewMessageFactoryWithRegistries(
-// NewExtensionRegistryWithDefaults(),
-// NewKnownTypeRegistryWithDefaults())
+//
+// NewMessageFactoryWithRegistries(
+// NewExtensionRegistryWithDefaults(),
+// NewKnownTypeRegistryWithDefaults())
func NewMessageFactoryWithDefaults() *MessageFactory {
return NewMessageFactoryWithRegistries(NewExtensionRegistryWithDefaults(), NewKnownTypeRegistryWithDefaults())
}
@@ -174,28 +175,33 @@
// GetKnownType will return the reflect.Type for the given message name if it is
// known. If it is not known, nil is returned.
func (r *KnownTypeRegistry) GetKnownType(messageName string) reflect.Type {
- var msgType reflect.Type
if r == nil {
// a nil registry behaves the same as zero value instance: only know of well-known types
t := proto.MessageType(messageName)
if t != nil && isWellKnownType(t) {
- msgType = t
+ return t
}
- } else {
- if r.includeDefault {
- msgType = proto.MessageType(messageName)
- } else if !r.excludeWkt {
- t := proto.MessageType(messageName)
- if t != nil && isWellKnownType(t) {
- msgType = t
- }
+ return nil
+ }
+
+ if r.includeDefault {
+ t := proto.MessageType(messageName)
+ if t != nil && isMessage(t) {
+ return t
}
- if msgType == nil {
- r.mu.RLock()
- msgType = r.types[messageName]
- r.mu.RUnlock()
+ } else if !r.excludeWkt {
+ t := proto.MessageType(messageName)
+ if t != nil && isWellKnownType(t) {
+ return t
}
}
- return msgType
+ r.mu.RLock()
+ defer r.mu.RUnlock()
+ return r.types[messageName]
+}
+
+func isMessage(t reflect.Type) bool {
+ _, ok := reflect.Zero(t).Interface().(proto.Message)
+ return ok
}
diff --git a/vendor/github.com/jhump/protoreflect/dynamic/text.go b/vendor/github.com/jhump/protoreflect/dynamic/text.go
index 5784d3e..5680dc2 100644
--- a/vendor/github.com/jhump/protoreflect/dynamic/text.go
+++ b/vendor/github.com/jhump/protoreflect/dynamic/text.go
@@ -15,7 +15,7 @@
"unicode"
"github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ "google.golang.org/protobuf/types/descriptorpb"
"github.com/jhump/protoreflect/codec"
"github.com/jhump/protoreflect/desc"
@@ -208,7 +208,7 @@
}
func marshalKnownFieldText(b *indentBuffer, fd *desc.FieldDescriptor, v interface{}) error {
- group := fd.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP
+ group := fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP
if group {
var name string
if fd.IsExtension() {
@@ -518,7 +518,7 @@
if fd == nil {
// See if it's a group name
for _, field := range m.md.GetFields() {
- if field.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP && field.GetMessageType().GetName() == fieldName {
+ if field.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP && field.GetMessageType().GetName() == fieldName {
fd = field
break
}
@@ -581,8 +581,8 @@
return err
}
- } else if (fd.GetType() == descriptor.FieldDescriptorProto_TYPE_GROUP ||
- fd.GetType() == descriptor.FieldDescriptorProto_TYPE_MESSAGE) &&
+ } else if (fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP ||
+ fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_MESSAGE) &&
tok.tokTyp.EndToken() != tokenError {
// TODO: use mf.NewMessage and, if not a dynamic message, use proto.UnmarshalText to unmarshal it
@@ -689,7 +689,7 @@
var expected string
switch fd.GetType() {
- case descriptor.FieldDescriptorProto_TYPE_BOOL:
+ case descriptorpb.FieldDescriptorProto_TYPE_BOOL:
if tok.tokTyp == tokenIdent {
if tok.val.(string) == "true" {
return set(m, fd, true)
@@ -698,17 +698,17 @@
}
}
expected = "boolean value"
- case descriptor.FieldDescriptorProto_TYPE_BYTES:
+ case descriptorpb.FieldDescriptorProto_TYPE_BYTES:
if tok.tokTyp == tokenString {
return set(m, fd, []byte(tok.val.(string)))
}
expected = "bytes string value"
- case descriptor.FieldDescriptorProto_TYPE_STRING:
+ case descriptorpb.FieldDescriptorProto_TYPE_STRING:
if tok.tokTyp == tokenString {
return set(m, fd, tok.val)
}
expected = "string value"
- case descriptor.FieldDescriptorProto_TYPE_FLOAT:
+ case descriptorpb.FieldDescriptorProto_TYPE_FLOAT:
switch tok.tokTyp {
case tokenFloat:
return set(m, fd, float32(tok.val.(float64)))
@@ -736,7 +736,7 @@
}
}
expected = "float value"
- case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
+ case descriptorpb.FieldDescriptorProto_TYPE_DOUBLE:
switch tok.tokTyp {
case tokenFloat:
return set(m, fd, tok.val)
@@ -764,9 +764,9 @@
}
}
expected = "float value"
- case descriptor.FieldDescriptorProto_TYPE_INT32,
- descriptor.FieldDescriptorProto_TYPE_SINT32,
- descriptor.FieldDescriptorProto_TYPE_SFIXED32:
+ case descriptorpb.FieldDescriptorProto_TYPE_INT32,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT32,
+ descriptorpb.FieldDescriptorProto_TYPE_SFIXED32:
if tok.tokTyp == tokenInt {
if i, err := strconv.ParseInt(tok.val.(string), 10, 32); err != nil {
return err
@@ -775,9 +775,9 @@
}
}
expected = "int value"
- case descriptor.FieldDescriptorProto_TYPE_INT64,
- descriptor.FieldDescriptorProto_TYPE_SINT64,
- descriptor.FieldDescriptorProto_TYPE_SFIXED64:
+ case descriptorpb.FieldDescriptorProto_TYPE_INT64,
+ descriptorpb.FieldDescriptorProto_TYPE_SINT64,
+ descriptorpb.FieldDescriptorProto_TYPE_SFIXED64:
if tok.tokTyp == tokenInt {
if i, err := strconv.ParseInt(tok.val.(string), 10, 64); err != nil {
return err
@@ -786,8 +786,8 @@
}
}
expected = "int value"
- case descriptor.FieldDescriptorProto_TYPE_UINT32,
- descriptor.FieldDescriptorProto_TYPE_FIXED32:
+ case descriptorpb.FieldDescriptorProto_TYPE_UINT32,
+ descriptorpb.FieldDescriptorProto_TYPE_FIXED32:
if tok.tokTyp == tokenInt {
if i, err := strconv.ParseUint(tok.val.(string), 10, 32); err != nil {
return err
@@ -796,8 +796,8 @@
}
}
expected = "unsigned int value"
- case descriptor.FieldDescriptorProto_TYPE_UINT64,
- descriptor.FieldDescriptorProto_TYPE_FIXED64:
+ case descriptorpb.FieldDescriptorProto_TYPE_UINT64,
+ descriptorpb.FieldDescriptorProto_TYPE_FIXED64:
if tok.tokTyp == tokenInt {
if i, err := strconv.ParseUint(tok.val.(string), 10, 64); err != nil {
return err
@@ -806,7 +806,7 @@
}
}
expected = "unsigned int value"
- case descriptor.FieldDescriptorProto_TYPE_ENUM:
+ case descriptorpb.FieldDescriptorProto_TYPE_ENUM:
if tok.tokTyp == tokenIdent {
// TODO: add a flag to just ignore unrecognized enum value names?
vd := fd.GetEnumType().FindValueByName(tok.val.(string))
@@ -821,8 +821,8 @@
}
}
expected = fmt.Sprintf("enum %s value", fd.GetEnumType().GetFullyQualifiedName())
- case descriptor.FieldDescriptorProto_TYPE_MESSAGE,
- descriptor.FieldDescriptorProto_TYPE_GROUP:
+ case descriptorpb.FieldDescriptorProto_TYPE_MESSAGE,
+ descriptorpb.FieldDescriptorProto_TYPE_GROUP:
endTok := tok.tokTyp.EndToken()
if endTok != tokenError {