Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonRpcServer does not support most method parameter types #378

Closed
weibeld opened this issue Jul 25, 2018 · 2 comments
Closed

JsonRpcServer does not support most method parameter types #378

weibeld opened this issue Jul 25, 2018 · 2 comments
Assignees
Milestone

Comments

@weibeld
Copy link

weibeld commented Jul 25, 2018

JsonRpcServer correctly resolves RPC requests for methods with any of the following parameter types:

  • primitive types
  • String
  • List
  • Map

But not for methods with any other parameter types (actually, strangely it also works with Integer and Double, but not with Long).

So, for example, a method that has a Set or Date parameter cannot be called through RPC via JsonRpcClient and JsonRpcServer. It results in the server returning the following "argument type mismatch" error message:

{
   "code":500,
   "name":"JSONRPCError",
   "message":"Internal Server Error",
   "error":{
      "localizedMessage":"argument type mismatch",
      "cause":null,
      "stackTrace":[
         {
            "fileName":"NativeMethodAccessorImpl.java",
            "nativeMethod":true,
            "methodName":"invoke0",
            "className":"sun.reflect.NativeMethodAccessorImpl",
            "lineNumber":-2
         },
         {
            "fileName":"NativeMethodAccessorImpl.java",
            "nativeMethod":false,
            "methodName":"invoke",
            "className":"sun.reflect.NativeMethodAccessorImpl",
            "lineNumber":62
         },
         {
            "fileName":"DelegatingMethodAccessorImpl.java",
            "nativeMethod":false,
            "methodName":"invoke",
            "className":"sun.reflect.DelegatingMethodAccessorImpl",
            "lineNumber":43
         },
         {
            "fileName":"Method.java",
            "nativeMethod":false,
            "methodName":"invoke",
            "className":"java.lang.reflect.Method",
            "lineNumber":497
         },
         {
            "fileName":"JsonRpcServer.java",
            "nativeMethod":false,
            "methodName":"doCall",
            "className":"com.rabbitmq.tools.jsonrpc.JsonRpcServer",
            "lineNumber":143
         },
         {
            "fileName":"JsonRpcServer.java",
            "nativeMethod":false,
            "methodName":"handleStringCall",
            "className":"com.rabbitmq.tools.jsonrpc.JsonRpcServer",
            "lineNumber":103
         },
         {
            "fileName":"StringRpcServer.java",
            "nativeMethod":false,
            "methodName":"handleCall",
            "className":"com.rabbitmq.client.StringRpcServer",
            "lineNumber":48
         },
         {
            "fileName":"RpcServer.java",
            "nativeMethod":false,
            "methodName":"handleCall",
            "className":"com.rabbitmq.client.RpcServer",
            "lineNumber":182
         },
         {
            "fileName":"RpcServer.java",
            "nativeMethod":false,
            "methodName":"handleCall",
            "className":"com.rabbitmq.client.RpcServer",
            "lineNumber":169
         },
         {
            "fileName":"RpcServer.java",
            "nativeMethod":false,
            "methodName":"processRequest",
            "className":"com.rabbitmq.client.RpcServer",
            "lineNumber":154
         },
         {
            "fileName":"RpcServer.java",
            "nativeMethod":false,
            "methodName":"mainloop",
            "className":"com.rabbitmq.client.RpcServer",
            "lineNumber":119
         },
         // Application specific classes...
      ],
      "suppressed":[

      ],
      "message":"argument type mismatch"
   }
}

On the other hand, return values of any type are passed to the RPC client correctly. The issue occurs only if the method has parameter types other than any of the above basic types.

This has also been asked by someone else on StackOverflow.

Versions:

  • amqp-client v5.3.0
  • RabbitMQ v3.7.3
@michaelklishin
Copy link
Member

The RPC client and server in this library primarly serve as examples. Feel free to look into a PR.

@acogoluegnes
Copy link
Contributor

A test case reproducing the issue would be a useful first step. And as suggested by @michaelklishin, a PR would be even better.

acogoluegnes added a commit that referenced this issue Jul 27, 2018
@acogoluegnes acogoluegnes self-assigned this Aug 1, 2018
@acogoluegnes acogoluegnes added this to the 4.8.0 milestone Aug 1, 2018
acogoluegnes added a commit that referenced this issue Aug 13, 2018
acogoluegnes added a commit that referenced this issue Aug 13, 2018
acogoluegnes added a commit that referenced this issue Aug 14, 2018
acogoluegnes added a commit that referenced this issue Aug 14, 2018
acogoluegnes added a commit that referenced this issue Aug 16, 2018
WIP

References #378

(cherry picked from commit 0a3bed1)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
WIP

References #378

(cherry picked from commit e28b34a)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
[#159302201]

Fixes #378

(cherry picked from commit 01f10d6)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
References #378

(cherry picked from commit d79a8b0)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
WIP

References #378

(cherry picked from commit 0a3bed1)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
WIP

References #378

(cherry picked from commit e28b34a)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
[#159302201]

Fixes #378

(cherry picked from commit 01f10d6)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
References #378

(cherry picked from commit d79a8b0)
acogoluegnes added a commit that referenced this issue Aug 16, 2018
acogoluegnes added a commit that referenced this issue Aug 17, 2018
References #378, #391

(cherry picked from commit 3f079cf)
acogoluegnes added a commit that referenced this issue Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants