[VOL-5486] Fix deprecated versions
Change-Id: Ic398322948171d8a1c5b4e866602805ec0ea396f
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/vendor/github.com/jhump/protoreflect/internal/standard_files.go b/vendor/github.com/jhump/protoreflect/internal/standard_files.go
index 4a8b47a..777c3a4 100644
--- a/vendor/github.com/jhump/protoreflect/internal/standard_files.go
+++ b/vendor/github.com/jhump/protoreflect/internal/standard_files.go
@@ -9,7 +9,7 @@
"io/ioutil"
"github.com/golang/protobuf/proto"
- dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
+ "google.golang.org/protobuf/types/descriptorpb"
)
// TODO: replace this alias configuration with desc.RegisterImportPath?
@@ -68,7 +68,7 @@
// name cannot be loaded but is a known standard name, an alias will be tried,
// so the standard files can be loaded even if linked against older "known bad"
// versions of packages.
-func LoadFileDescriptor(file string) (*dpb.FileDescriptorProto, error) {
+func LoadFileDescriptor(file string) (*descriptorpb.FileDescriptorProto, error) {
fdb := proto.FileDescriptor(file)
aliased := false
if fdb == nil {
@@ -102,12 +102,12 @@
// Registered file descriptors are first "proto encoded" (e.g. binary format
// for the descriptor protos) and then gzipped. So this function gunzips and
// then unmarshals into a descriptor proto.
-func DecodeFileDescriptor(element string, fdb []byte) (*dpb.FileDescriptorProto, error) {
+func DecodeFileDescriptor(element string, fdb []byte) (*descriptorpb.FileDescriptorProto, error) {
raw, err := decompress(fdb)
if err != nil {
return nil, fmt.Errorf("failed to decompress %q descriptor: %v", element, err)
}
- fd := dpb.FileDescriptorProto{}
+ fd := descriptorpb.FileDescriptorProto{}
if err := proto.Unmarshal(raw, &fd); err != nil {
return nil, fmt.Errorf("bad descriptor for %q: %v", element, err)
}
diff --git a/vendor/github.com/jhump/protoreflect/internal/unrecognized.go b/vendor/github.com/jhump/protoreflect/internal/unrecognized.go
index c903d4b..25376c7 100644
--- a/vendor/github.com/jhump/protoreflect/internal/unrecognized.go
+++ b/vendor/github.com/jhump/protoreflect/internal/unrecognized.go
@@ -1,86 +1,20 @@
package internal
import (
- "reflect"
-
"github.com/golang/protobuf/proto"
)
-var typeOfBytes = reflect.TypeOf([]byte(nil))
-
// GetUnrecognized fetches the bytes of unrecognized fields for the given message.
func GetUnrecognized(msg proto.Message) []byte {
- val := reflect.Indirect(reflect.ValueOf(msg))
- u := val.FieldByName("XXX_unrecognized")
- if u.IsValid() && u.Type() == typeOfBytes {
- return u.Interface().([]byte)
- }
-
- // Fallback to reflection for API v2 messages
- get, _, _, ok := unrecognizedGetSetMethods(val)
- if !ok {
- return nil
- }
-
- return get.Call([]reflect.Value(nil))[0].Convert(typeOfBytes).Interface().([]byte)
+ return proto.MessageReflect(msg).GetUnknown()
}
// SetUnrecognized adds the given bytes to the unrecognized fields for the given message.
func SetUnrecognized(msg proto.Message, data []byte) {
- val := reflect.Indirect(reflect.ValueOf(msg))
- u := val.FieldByName("XXX_unrecognized")
- if u.IsValid() && u.Type() == typeOfBytes {
- // Just store the bytes in the unrecognized field
- ub := u.Interface().([]byte)
- ub = append(ub, data...)
- u.Set(reflect.ValueOf(ub))
- return
- }
-
- // Fallback to reflection for API v2 messages
- get, set, argType, ok := unrecognizedGetSetMethods(val)
- if !ok {
- return
- }
-
- existing := get.Call([]reflect.Value(nil))[0].Convert(typeOfBytes).Interface().([]byte)
+ refl := proto.MessageReflect(msg)
+ existing := refl.GetUnknown()
if len(existing) > 0 {
data = append(existing, data...)
}
- set.Call([]reflect.Value{reflect.ValueOf(data).Convert(argType)})
-}
-
-func unrecognizedGetSetMethods(val reflect.Value) (get reflect.Value, set reflect.Value, argType reflect.Type, ok bool) {
- // val could be an APIv2 message. We use reflection to interact with
- // this message so that we don't have a hard dependency on the new
- // version of the protobuf package.
- refMethod := val.MethodByName("ProtoReflect")
- if !refMethod.IsValid() {
- if val.CanAddr() {
- refMethod = val.Addr().MethodByName("ProtoReflect")
- }
- if !refMethod.IsValid() {
- return
- }
- }
- refType := refMethod.Type()
- if refType.NumIn() != 0 || refType.NumOut() != 1 {
- return
- }
- ref := refMethod.Call([]reflect.Value(nil))
- getMethod, setMethod := ref[0].MethodByName("GetUnknown"), ref[0].MethodByName("SetUnknown")
- if !getMethod.IsValid() || !setMethod.IsValid() {
- return
- }
- getType := getMethod.Type()
- setType := setMethod.Type()
- if getType.NumIn() != 0 || getType.NumOut() != 1 || setType.NumIn() != 1 || setType.NumOut() != 0 {
- return
- }
- arg := setType.In(0)
- if !arg.ConvertibleTo(typeOfBytes) || getType.Out(0) != arg {
- return
- }
-
- return getMethod, setMethod, arg, true
+ refl.SetUnknown(data)
}