jnan77 / jsonrpc4j

Automatically exported from code.google.com/p/jsonrpc4j
0 stars 0 forks source link

Support for overloaded methods with the same number of parameters #13

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Create a service class with two overloaded methods with the same number of 
parameters but different parameters' types, e.g. doSth(String, String) and 
doSth(String, List)
2. Annotate the parameters with unique names using @JsonRpcParamName, e.g. 
"strParam1" and "strParam2" for doSth(String, String) and "strParam" and 
"listParam" for doSth(String, List)
3. Make two JSON-RPC calls: first with "strParam1" and "strParam2" parameters 
and second with "strParam" and "listParam". 

What is the expected output? What do you see instead?

Expected behavior: matching methods are found using incoming parameters' names, 
i.e. first call executes doSth(String, String) method and second call executes 
doSth(String, List) method. 

Current behavior: both calls execute the same version of the method. Which one 
of the two is chosen seems to be random. In my case doSth(String, String) 
method is called. It runs fine for the first call but the second one results in 
a following exception:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at com.googlecode.jsonrpc4j.JsonRpcServer.invoke(JsonRpcServer.java:521)
    at com.googlecode.jsonrpc4j.JsonRpcServer.handleObject(JsonRpcServer.java:425)
    at com.googlecode.jsonrpc4j.JsonRpcServer.handleNode(JsonRpcServer.java:250)
    at com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:192)
    at Main.callDoSth(Main.java:65)
    at Main.main(Main.java:48)

What version of the product are you using? On what operating system?

Versions tested: 0.18 and trunk version (0.19 SNAPSHOT)
OS: MacOSX

Please provide any additional information below.

Fixing this issue seems to be pretty straightforward. It only requires a small 
change in JsonRpcServer class (see the patch in an attachment).

Original issue reported on code.google.com by pkupc...@gmail.com on 26 Jan 2012 at 8:30

Attachments:

GoogleCodeExporter commented 8 years ago
Test project for the described scenario

Original comment by pkupc...@gmail.com on 26 Jan 2012 at 8:38

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks pkupczyk for your detail bug report with patch and sample project.  I've 
committed the change and it will be included in the next release of the project.

Original comment by brian.di...@gmail.com on 8 Feb 2012 at 7:48

GoogleCodeExporter commented 8 years ago

Original comment by brian.di...@gmail.com on 25 May 2012 at 2:51

GoogleCodeExporter commented 8 years ago

Original comment by brian.di...@gmail.com on 26 May 2012 at 2:45