diff options
author | 2018-05-16 14:19:53 -0700 | |
---|---|---|
committer | 2018-05-16 22:19:53 +0100 | |
commit | 05a030e17b43ac5d19a427c30d203d93f61c9f03 (patch) | |
tree | cf1df82b9ad1a2ae1ff495599f6597dc989e0963 /vendor/github.com/go-openapi/swag/json.go | |
parent | 1e471a353ecfaf4bc7df06d9528ae7e312497dac (diff) | |
download | coredns-05a030e17b43ac5d19a427c30d203d93f61c9f03.tar.gz coredns-05a030e17b43ac5d19a427c30d203d93f61c9f03.tar.zst coredns-05a030e17b43ac5d19a427c30d203d93f61c9f03.zip |
Vendor update with github.com/ugorji/go and github.com/apache/thrift pinning (#1805)
This fix is an vendor update. Both ugorji and thrift have to be pinned
to compile. The ugorji is from etcd and thrift is from zipkin.
This fix fixes #1802.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Diffstat (limited to 'vendor/github.com/go-openapi/swag/json.go')
-rw-r--r-- | vendor/github.com/go-openapi/swag/json.go | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/vendor/github.com/go-openapi/swag/json.go b/vendor/github.com/go-openapi/swag/json.go index cb20a6a0f..274331ef1 100644 --- a/vendor/github.com/go-openapi/swag/json.go +++ b/vendor/github.com/go-openapi/swag/json.go @@ -26,6 +26,9 @@ import ( "github.com/mailru/easyjson/jwriter" ) +// nullJSON represents a JSON object with null type +var nullJSON = []byte("null") + // DefaultJSONNameProvider the default cache for types var DefaultJSONNameProvider = NewNameProvider() @@ -90,17 +93,29 @@ func ConcatJSON(blobs ...[]byte) []byte { if len(blobs) == 0 { return nil } - if len(blobs) == 1 { + + last := len(blobs) - 1 + for blobs[last] == nil || bytes.Equal(blobs[last], nullJSON) { + // strips trailing null objects + last = last - 1 + if last < 0 { + // there was nothing but "null"s or nil... + return nil + } + } + if last == 0 { return blobs[0] } - last := len(blobs) - 1 var opening, closing byte - a := 0 - idx := 0 + var idx, a int buf := bytes.NewBuffer(nil) - for i, b := range blobs { + for i, b := range blobs[:last+1] { + if b == nil || bytes.Equal(b, nullJSON) { + // a null object is in the list: skip it + continue + } if len(b) > 0 && opening == 0 { // is this an array or an object? opening, closing = b[0], closers[b[0]] } |