diff --git a/common/logger/logger.go b/common/logger/logger.go index 63eda231ddd174468602577d8b042bc0664700d0..4a2f07cb30ee6b5840a3915b441ae0a554f5d5cb 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -163,6 +163,7 @@ type OpsLogger interface { // SetLoggerLevel use for set logger level func (dl *DubboLogger) SetLoggerLevel(level string) { l := new(zapcore.Level) - l.Set(level) - dl.dynamicLevel.SetLevel(*l) + if err := l.Set(level); err == nil { + dl.dynamicLevel.SetLevel(*l) + } } diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go index c6f659666180310887f2101966e59669df707e54..cbac1f3bb4e5c793e19cd0b56ff1aab515aadb9e 100644 --- a/common/proxy/proxy_test.go +++ b/common/proxy/proxy_test.go @@ -19,6 +19,7 @@ package proxy import ( "context" + "fmt" "reflect" "testing" ) @@ -145,11 +146,14 @@ type TestProxyInvoker struct { protocol.BaseInvoker } -func (bi *TestProxyInvoker) Invoke(context context.Context, inv protocol.Invocation) protocol.Result { +func (bi *TestProxyInvoker) Invoke(_ context.Context, inv protocol.Invocation) protocol.Result { rpcInv := inv.(*invocation.RPCInvocation) mapV := inv.Attachments() mapV["TestProxyInvoker"] = "TestProxyInvokerValue" - hessian2.ReflectResponse(mapV, rpcInv.Reply()) + if err := hessian2.ReflectResponse(mapV, rpcInv.Reply()); err != nil { + fmt.Printf("hessian2.ReflectResponse(mapV:%v) = error:%v", mapV, err) + } + return &protocol.RPCResult{ Rest: inv.Arguments(), } diff --git a/common/url.go b/common/url.go index 1ea2bc4321afcf93f148fea07019a892966fd720..8faa0f08ce004441619898e8cc451102c7ddc796 100644 --- a/common/url.go +++ b/common/url.go @@ -21,7 +21,6 @@ import ( "bytes" "encoding/base64" "fmt" - cm "github.com/Workiva/go-datastructures/common" "math" "net" "net/url" @@ -31,7 +30,9 @@ import ( ) import ( + cm "github.com/Workiva/go-datastructures/common" gxset "github.com/dubbogo/gost/container/set" + "github.com/jinzhu/copier" perrors "github.com/pkg/errors" "github.com/satori/go.uuid" @@ -217,12 +218,12 @@ func WithToken(token string) Option { // NewURLWithOptions will create a new url with options func NewURLWithOptions(opts ...Option) *URL { - newUrl := &URL{} + newURL := &URL{} for _, opt := range opts { - opt(newUrl) + opt(newURL) } - newUrl.Location = newUrl.Ip + ":" + newUrl.Port - return newUrl + newURL.Location = newURL.Ip + ":" + newURL.Port + return newURL } // NewURL will create a new url @@ -679,27 +680,34 @@ func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL { // Clone will copy the url func (c *URL) Clone() *URL { - newUrl := &URL{} - copier.Copy(newUrl, c) - newUrl.params = url.Values{} + newURL := &URL{} + if err := copier.Copy(newURL, c); err != nil { + // this is impossible + return newURL + } + newURL.params = url.Values{} c.RangeParams(func(key, value string) bool { - newUrl.SetParam(key, value) + newURL.SetParam(key, value) return true }) - return newUrl + + return newURL } func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL { - newUrl := &URL{} - copier.Copy(newUrl, c) - newUrl.params = url.Values{} + newURL := &URL{} + if err := copier.Copy(newURL, c); err != nil { + // this is impossible + return newURL + } + newURL.params = url.Values{} c.RangeParams(func(key, value string) bool { if !excludeParams.Contains(key) { - newUrl.SetParam(key, value) + newURL.SetParam(key, value) } return true }) - return newUrl + return newURL } func (c *URL) Compare(comp cm.Comparator) int {