Skip to content
Snippets Groups Projects
Commit 61171b32 authored by Patrick's avatar Patrick
Browse files

fix

parent 08a246c8
No related branches found
No related tags found
No related merge requests found
...@@ -58,6 +58,7 @@ func (ef *GenericServiceFilter) Invoke(invoker protocol.Invoker, invocation prot ...@@ -58,6 +58,7 @@ func (ef *GenericServiceFilter) Invoke(invoker protocol.Invoker, invocation prot
} }
var ( var (
ok bool
err error err error
methodName string methodName string
newParams []interface{} newParams []interface{}
...@@ -79,26 +80,30 @@ func (ef *GenericServiceFilter) Invoke(invoker protocol.Invoker, invocation prot ...@@ -79,26 +80,30 @@ func (ef *GenericServiceFilter) Invoke(invoker protocol.Invoker, invocation prot
argsType = method.ArgsType() argsType = method.ArgsType()
genericKey = invocation.AttachmentsByKey(constant.GENERIC_KEY, GENERIC_SERIALIZATION_DEFAULT) genericKey = invocation.AttachmentsByKey(constant.GENERIC_KEY, GENERIC_SERIALIZATION_DEFAULT)
if genericKey == GENERIC_SERIALIZATION_DEFAULT { if genericKey == GENERIC_SERIALIZATION_DEFAULT {
oldParams = invocation.Arguments()[2].([]hessian.Object) oldParams, ok = invocation.Arguments()[2].([]hessian.Object)
} else { } else {
logger.Errorf("[Generic Service Filter] Don't support this generic: %s", genericKey) logger.Errorf("[Generic Service Filter] Don't support this generic: %s", genericKey)
return &protocol.RPCResult{} return &protocol.RPCResult{}
} }
if !ok {
logger.Errorf("[Generic Service Filter] wrong serialization")
return &protocol.RPCResult{}
}
if len(oldParams) != len(argsType) { if len(oldParams) != len(argsType) {
logger.Errorf("[Generic Service Filter] method:%s invocation arguments number was wrong", methodName) logger.Errorf("[Generic Service Filter] method:%s invocation arguments number was wrong", methodName)
return &protocol.RPCResult{} return &protocol.RPCResult{}
} }
// oldParams convert to newParams // oldParams convert to newParams
newParams = make([]interface{}, len(oldParams))
for i := range argsType { for i := range argsType {
var newParam interface{} newParam := reflect.New(argsType[i]).Interface()
newParam = reflect.New(argsType[i]).Interface()
err = mapstructure.Decode(oldParams[i], newParam) err = mapstructure.Decode(oldParams[i], newParam)
newParam = reflect.ValueOf(newParam).Elem().Interface() newParam = reflect.ValueOf(newParam).Elem().Interface()
if err != nil { if err != nil {
logger.Errorf("[Generic Service Filter] decode arguments map to struct wrong: error{%v}", perrors.WithStack(err)) logger.Errorf("[Generic Service Filter] decode arguments map to struct wrong: error{%v}", perrors.WithStack(err))
return &protocol.RPCResult{} return &protocol.RPCResult{}
} }
newParams = append(newParams, newParam) newParams[i] = newParam
} }
newInvocation := invocation2.NewRPCInvocation(methodName, newParams, invocation.Attachments()) newInvocation := invocation2.NewRPCInvocation(methodName, newParams, invocation.Attachments())
newInvocation.SetReply(invocation.Reply()) newInvocation.SetReply(invocation.Reply())
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment