You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-auto@ws.apache.org by "kamin (JIRA)" <xm...@ws.apache.org> on 2006/12/21 15:59:24 UTC
[jira] Created: (XMLRPC-129) typecast errors when arrays are
returned
typecast errors when arrays are returned
----------------------------------------
Key: XMLRPC-129
URL: http://issues.apache.org/jira/browse/XMLRPC-129
Project: XML-RPC
Issue Type: Bug
Components: Source
Affects Versions: 3.0
Environment: linux, java 1.4.2
Reporter: kamin
Java throws a ClassCastException when an array return value is cast to a typed array, for XML-RPC functions that return arrays.
For example, the function
public Integer[] foo(Integer[] val){ return val; }
will work fine with the following client code:
Integer[] param = new Integer[5];
Object[] result = (Object[])server.execute("Server.foo", param);
But the following will throw a class cast exception
Integer[] param = new Integer[5];
Integer[] result = (Integer[])server.execute("Server.foo", param);
This error was first documented on the mailing list in this thread:
http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-dev/200609.mbox/%3c19c34bd10609220214g170174e2mdb9082f1aacb0537@mail.gmail.com%3e
The response to the email suggests that this should be easy to fix.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
Re: [jira] Created: (XMLRPC-129) typecast errors when arrays are returned
Posted by Jochen Wiedmann <jo...@gmail.com>.
On 12/21/06, kamin (JIRA) <xm...@ws.apache.org> wrote:
> For example, the function
>
> public Integer[] foo(Integer[] val){ return val; }
>
> will work fine with the following client code:
>
> Integer[] param = new Integer[5];
> Object[] result = (Object[])server.execute("Server.foo", param);
There's no possibility to get something else than an Object[] unless
you are using the ClientFactory (see the section on "Dynamic Proxies"
in http://ws.apache.org/xmlrpc/advanced.html).
Jochen
--
My wife Mary and I have been married for forty-seven years and not
once have we had an argument serious enough to consider divorce;
murder, yes, but divorce, never.
(Jack Benny)
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
[jira] Resolved: (XMLRPC-129) typecast errors when arrays are
returned
Posted by "Jochen Wiedmann (JIRA)" <xm...@ws.apache.org>.
[ https://issues.apache.org/jira/browse/XMLRPC-129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jochen Wiedmann resolved XMLRPC-129.
------------------------------------
Resolution: Invalid
I have added the following entry to the FAQ:
<faq id="arrays">
<question>Why do I receive a ClassCastException, if the server returns an array?</question>
<answer>
<p>The problem is typically caused by code like the following:</p>
<source><![CDATA[
Integer[] result = (Integer[])server.execute("Server.foo", param);
]]></source>
<p>The problem is in the fact, that the XML-RPC response tells
the client, that the server returns an array. It doesn't tell
what type the array has. In other words, the client will
always receive an object array. The workaround is to use
code like the following:</p>
<source><![CDATA[
Object[] result = (Integer[])server.execute("Server.foo", param);
for (int i = 0; i < result.length; i++) {
Integer num = (Integer) result[i];
...
}
]]></source>
</answer>
</faq>
> typecast errors when arrays are returned
> ----------------------------------------
>
> Key: XMLRPC-129
> URL: https://issues.apache.org/jira/browse/XMLRPC-129
> Project: XML-RPC
> Issue Type: Bug
> Components: Source
> Affects Versions: 3.0
> Environment: linux, java 1.4.2
> Reporter: kamin
>
> Java throws a ClassCastException when an array return value is cast to a typed array, for XML-RPC functions that return arrays.
> For example, the function
> public Integer[] foo(Integer[] val){ return val; }
> will work fine with the following client code:
> Integer[] param = new Integer[5];
> Object[] result = (Object[])server.execute("Server.foo", param);
> But the following will throw a class cast exception
> Integer[] param = new Integer[5];
> Integer[] result = (Integer[])server.execute("Server.foo", param);
> This error was first documented on the mailing list in this thread:
> http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-dev/200609.mbox/%3c19c34bd10609220214g170174e2mdb9082f1aacb0537@mail.gmail.com%3e
> The response to the email suggests that this should be easy to fix.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.