You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/11/11 07:13:16 UTC

[GitHub] [dubbo-go] PhilYue opened a new issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

PhilYue opened a new issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582


   <!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!
   
   -->
   
   **What happened**:
   基于当前的 [JSON-RPC](https://github.com/apache/dubbo-go-samples/tree/master/rpc/jsonrpc) 示例,**将调用接口方法入参与出参都改造为 `struct` 后**,Server 端抛出异常,方法无法正常执行。
   Client 改造后方法
   ```
           logger.Infof("\n\n\nstart to test jsonrpc")
   
   	user := &pkg.JsonRPCUser{
   		ID: "A003",
   	}
   	user, err := userProvider.GetUser(context.TODO(), user)
   
   	if err != nil {
   		panic(err)
   	}
   	logger.Infof("response result: %v", user)
   ```
   Server 改造后方法
   ```
   func (u *UserProvider) GetUser(ctx context.Context, userID *User) (*User, error) {
   	var (
   		err  error
   		user *User
   	)
   
   	gxlog.CInfo("userID:%#v", userID)
   	user, err = u.getUser(userID.ID)
   	if err == nil {
   		gxlog.CInfo("rsp:%#v", user)
   	}
   	return user, err
   }
   ```
   Client 异常日志
   ```
   start to test jsonrpc
   2021-11-11T14:53:49.338+0800    WARN    proxy/proxy.go:215      result err: unexpected EOF
   panic: unexpected EOF
   ```
   Server 异常日志
   ```
   2021-11-11T15:02:15.525+0800    WARN    jsonrpc/server.go:81    connection{local:127.0.0.1:20001, remote:127.0.0.1:59593} panic error:"reflect: Call using map[string]interface {} as type *pkg.User", debug stack:goroutine 1684 [running]:
   runtime/debug.Stack(0x0, 0x0, 0x0)
           /usr/local/go/src/runtime/debug/stack.go:24 +0xa5
   dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.(*Server).handlePkg.func1(0x5723fc8, 0xc0003ec030)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:82 +0xd5
   panic(0x538c660, 0xc000947990)
           /usr/local/go/src/runtime/panic.go:971 +0x4c7
   reflect.Value.call(0xc0004b0600, 0xc000010250, 0x13, 0x55ec16f, 0x4, 0xc000950ba0, 0x3, 0x4, 0x0, 0x0, ...)
           /usr/local/go/src/reflect/value.go:406 +0x1bba
   reflect.Value.Call(0xc0004b0600, 0xc000010250, 0x13, 0xc000950ba0, 0x3, 0x4, 0x0, 0x0, 0x0)
           /usr/local/go/src/reflect/value.go:337 +0xcc
   dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory.(*ProxyInvoker).Invoke(0xc0000e43f0, 0x571a5f8, 0xc00038ab70, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/common/proxy/proxy_factory/default.go:145 +0x8e5
   dubbo.apache.org/dubbo-go/v3/registry/protocol.(*wrappedInvoker).Invoke(0xc00052a840, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/registry/protocol/protocol.go:452 +0x6e
   dubbo.apache.org/dubbo-go/v3/filter/gshutdown.(*Filter).Invoke(0xc000466be0, 0x571a5c0, 0xc000950b40, 0x571aba8, 0xc00052a840, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/gshutdown/filter.go:56 +0x20f
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a870, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/execlmt.(*Filter).Invoke(0xc000010050, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a870, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/execlmt/filter.go:101 +0x4e2
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a8a0, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/generic.(*ServiceFilter).Invoke(0x5fbfd28, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a8a0, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/generic/service_filter.go:51 +0x1029
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a8d0, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/tps.(*Filter).Invoke(0x5fbfd28, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a8d0, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/tps/filter.go:69 +0x41d
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a900, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/accesslog.(*Filter).Invoke(0xc000010218, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a900, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/accesslog/filter.go:89 +0x1b7
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a930, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/token.(*Filter).Invoke(0x5fbfd28, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a930, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/token/filter.go:58 +0x57c
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a960, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/metrics.(*Filter).Invoke(0xc0004aaa38, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a960, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/metrics/filter.go:49 +0xb2
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a990, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/filter/echo.(*Filter).Invoke(0x5fbfd28, 0x571a5c0, 0xc000950b40, 0x571aac8, 0xc00052a990, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/filter/echo/filter.go:54 +0x47c
   dubbo.apache.org/dubbo-go/v3/protocol/protocolwrapper.(*FilterInvoker).Invoke(0xc00052a9c0, 0x571a5c0, 0xc000950b40, 0x57267e0, 0xc000e53110, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/protocolwrapper/protocol_filter_wrapper.go:119 +0xb4
   dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.serveRequest(0x571a5c0, 0xc000950b40, 0xc00038a9f0, 0xc00096b200, 0x72, 0x200, 0x5723fc8, 0xc0003ec030, 0x0, 0x0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:349 +0x9ce
   dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.(*Server).handlePkg(0xc00007c180, 0x5723fc8, 0xc0003ec030)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:178 +0xf6a
   dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.(*Server).Start.func1.1(0x5723fc8, 0xc0003ec030)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:243 +0x45
   dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.accept.func1(0x5723fc8, 0xc0003ec030, 0xc0000d80b0)
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:227 +0x85
   created by dubbo.apache.org/dubbo-go/v3/protocol/jsonrpc.accept
           /Users/phil/go/pkg/mod/dubbo.apache.org/dubbo-go/v3@v3.0.0-rc3.0.20211109121610-2ebc38bed562/protocol/jsonrpc/server.go:216 +0x3e8
   
   ```
   
   **What you expected to happen**:
   
   Server 正常执行 `GetUser` 方法,并返回结果,Client 正常输出日志信息
   
   **How to reproduce it (as minimally and precisely as possible)**:
   -
   
   **Anything else we need to know?**:
   
   可能原因:Dubbo-go 服务代理执行时,参数类型没有得到正确解析。
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] PhilYue commented on issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

Posted by GitBox <gi...@apache.org>.
PhilYue commented on issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582#issuecomment-966047418


   @PhilYue 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] PhilYue edited a comment on issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

Posted by GitBox <gi...@apache.org>.
PhilYue edited a comment on issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582#issuecomment-966064892


   [dubbo-go/common/proxy/proxy_factory/default.go#Invoke](https://github.com/apache/dubbo-go/blob/master/common/proxy/proxy_factory/default.go#L86)
   
   ```go
   for i := 0; i < len(args); i++ {
   	t := reflect.ValueOf(args[i])
   	//if !t.IsValid() {
   	if t.IsValid() {
   		at := method.ArgsType()[i]
   		if at.Kind() == reflect.Ptr {
   			at = at.Elem()
   		}
   		t = reflect.New(at)
   	}
   	in = append(in, t)
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] PhilYue commented on issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

Posted by GitBox <gi...@apache.org>.
PhilYue commented on issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582#issuecomment-966064892


   ```go
   for i := 0; i < len(args); i++ {
   	t := reflect.ValueOf(args[i])
   	//if !t.IsValid() {
   	if t.IsValid() {
   		at := method.ArgsType()[i]
   		if at.Kind() == reflect.Ptr {
   			at = at.Elem()
   		}
   		t = reflect.New(at)
   	}
   	in = append(in, t)
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] PhilYue commented on issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

Posted by GitBox <gi...@apache.org>.
PhilYue commented on issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582#issuecomment-990751301


   suspend...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] justxuewei closed issue #1582: [JSON-RPC] panic error:"reflect: Call using map[string]interface {} as type *pkg.User"

Posted by GitBox <gi...@apache.org>.
justxuewei closed issue #1582:
URL: https://github.com/apache/dubbo-go/issues/1582


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org