From 53849095098973c9042db710e9e19c64b0c0bf9e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 26 Aug 2019 12:17:44 +0200 Subject: [PATCH] bump hashicorp/go-msgpack v0.5.5 full diff: https://github.com/hashicorp/go-msgpack/compare/71c2886f5a673a35f909803f38ece5810165097b...v0.5.5 - hashicorp/go-msgpack#3 Add go.mod - hashicorp/go-msgpack#7 Do not attempt to set unsettable types - hashicorp/go-msgpack#8 codec: do not dereference pointers/interfaces for omitempty support - backport of https://github.com/hashicorp/go-msgpack/commit/006e1534301cb75b848ee452ab5d3ba8c6a70784 - backport of https://github.com/hashicorp/go-msgpack/commit/006e1534301cb75b848ee452ab5d3ba8c6a70784 - fixes https://github.com/ugorji/go/issues/67 "omitempty" fails on pointers to bools Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- .../github.com/hashicorp/go-msgpack/codec/decode.go | 2 +- .../github.com/hashicorp/go-msgpack/codec/helper.go | 7 +++++++ .../hashicorp/go-msgpack/codec/helper_internal.go | 13 +++++++++---- vendor/github.com/hashicorp/go-msgpack/go.mod | 1 + 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-msgpack/go.mod diff --git a/vendor.conf b/vendor.conf index 49f77b003f..d4c739115a 100644 --- a/vendor.conf +++ b/vendor.conf @@ -27,7 +27,7 @@ github.com/godbus/dbus 5f6efc7ef2759c81b7ba876593971bfce311eab3 github.com/gorilla/mux c5c6c98bc25355028a63748a498942a6398ccd22 # v1.7.1 github.com/hashicorp/consul 9a9cc9341bb487651a0399e3fc5e1e8a42e62dd9 # v0.5.2 github.com/hashicorp/errwrap 8a6fb523712970c966eefc6b39ed2c5e74880354 # v1.0.0 -github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b +github.com/hashicorp/go-msgpack ad60660ecf9c5a1eae0ca32182ed72bab5807961 # v0.5.5 github.com/hashicorp/go-multierror 886a7fbe3eb1c874d46f623bfa70af45f425b3d1 # v1.0.0 github.com/hashicorp/memberlist e1138a6a4d8a6eaec6c919aeae5efbe4d69b1ece # v0.1.4 github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372 diff --git a/vendor/github.com/hashicorp/go-msgpack/codec/decode.go b/vendor/github.com/hashicorp/go-msgpack/codec/decode.go index 87bef2b935..851b54ac7e 100644 --- a/vendor/github.com/hashicorp/go-msgpack/codec/decode.go +++ b/vendor/github.com/hashicorp/go-msgpack/codec/decode.go @@ -527,7 +527,7 @@ func (f *decFnInfo) kMap(rv reflect.Value) { } } rvv := rv.MapIndex(rvk) - if !rvv.IsValid() { + if !rvv.IsValid() || !rvv.CanSet() { rvv = reflect.New(vtype).Elem() } diff --git a/vendor/github.com/hashicorp/go-msgpack/codec/helper.go b/vendor/github.com/hashicorp/go-msgpack/codec/helper.go index e6dc0563f0..7da3955edc 100644 --- a/vendor/github.com/hashicorp/go-msgpack/codec/helper.go +++ b/vendor/github.com/hashicorp/go-msgpack/codec/helper.go @@ -45,6 +45,13 @@ const ( // for debugging, set this to false, to catch panic traces. // Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic. recoverPanicToErr = true + + // if checkStructForEmptyValue, check structs fields to see if an empty value. + // This could be an expensive call, so possibly disable it. + checkStructForEmptyValue = false + + // if derefForIsEmptyValue, deref pointers and interfaces when checking isEmptyValue + derefForIsEmptyValue = false ) type charEncoding uint8 diff --git a/vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go b/vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go index 58417da958..93f12854f2 100644 --- a/vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go +++ b/vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go @@ -33,8 +33,10 @@ func panicValToErr(panicVal interface{}, err *error) { return } -func isEmptyValueDeref(v reflect.Value, deref bool) bool { +func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool { switch v.Kind() { + case reflect.Invalid: + return true case reflect.Array, reflect.Map, reflect.Slice, reflect.String: return v.Len() == 0 case reflect.Bool: @@ -50,18 +52,21 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool { if v.IsNil() { return true } - return isEmptyValueDeref(v.Elem(), deref) + return hIsEmptyValue(v.Elem(), deref, checkStruct) } else { return v.IsNil() } case reflect.Struct: + if !checkStruct { + return false + } // return true if all fields are empty. else return false. // we cannot use equality check, because some fields may be maps/slices/etc // and consequently the structs are not comparable. // return v.Interface() == reflect.Zero(v.Type()).Interface() for i, n := 0, v.NumField(); i < n; i++ { - if !isEmptyValueDeref(v.Field(i), deref) { + if !hIsEmptyValue(v.Field(i), deref, checkStruct) { return false } } @@ -71,7 +76,7 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool { } func isEmptyValue(v reflect.Value) bool { - return isEmptyValueDeref(v, true) + return hIsEmptyValue(v, derefForIsEmptyValue, checkStructForEmptyValue) } func debugf(format string, args ...interface{}) { diff --git a/vendor/github.com/hashicorp/go-msgpack/go.mod b/vendor/github.com/hashicorp/go-msgpack/go.mod new file mode 100644 index 0000000000..2c92e7fd22 --- /dev/null +++ b/vendor/github.com/hashicorp/go-msgpack/go.mod @@ -0,0 +1 @@ +module github.com/hashicorp/go-msgpack