You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "philippe le berre (JIRA)" <ji...@apache.org> on 2014/11/12 18:02:33 UTC

[jira] [Updated] (AXIS2-5676) Deserialisation of array of obj fails if the class has a constructor(string s)

     [ https://issues.apache.org/jira/browse/AXIS2-5676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

philippe le berre updated AXIS2-5676:
-------------------------------------
    Description: 
For instance,

public class Alice {
private String comment;
private String name;

public Alice();
public Alice(String comment)  {this.comment = comment; }
public String toString() { return "[name:"+name+", comment:"+comment+"]"; }
}

if invoking :
client.setReturnType(new Class[] {  Alice[].class });
Alice[] ar = (Alice[]) client.invokeBlocking(new Object[3]);

Then the deserialised array contains object instantiated with calls to Alice(obj.toString()). If one removes the Alice(String s) constructor then the array is correct, Alice objects are instantiated properly.

The root cause is the method ConvertToArbitraryObjectArray in org.apache.axis2.databinding.utils.ConverterUtil

---
                       Array.set(returnArray, i, getObjectForClass(
                                baseArrayClass,
                                o.toString()));
---

The one test that refers to this is testBigInteger in ConverterUtilTest, so I propose the following fix :

      if (! ADBBean.class.isAssignableFrom(baseArrayClass) && 
        		java.lang.Number.class.isAssignableFrom(baseArrayClass)) {

The ConvertUtilTest is then ok, as well as any array of Alice !



  was:
For instance,

public class Alice {
private String comment;
private String name;

public Alice();
public Alice(String comment)  {this.comment = comment; }
public String toString() { return "[name:"+name+", comment:"+comment+"]"; }
}

if invoking :
client.setReturnType(new Class[] {  Alice[].class });
Alice[] ar = (Alice[]) client.invokeBlocking(new Object[3]);

Then the deserialised array contains object instantiated with calls to Alice(obj.toString()). If one removes the Alice(String s) constructor then the array is correct, Alice objects are instantiated properly.

The root cause is the method ConvertToArbitraryObjectArray in org.apache.axis2.databinding.utils.ConverterUtil

---
                       Array.set(returnArray, i, getObjectForClass(
                                baseArrayClass,
                                o.toString()));
---

I just don't understand the purpose of the first half of the method, which silently trap exceptions. It works fine without it, the toArray is quite enough and doesn't induce weird assumptions on the handled objects. 




> Deserialisation of array of obj fails if the class has a constructor(string s)
> ------------------------------------------------------------------------------
>
>                 Key: AXIS2-5676
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5676
>             Project: Axis2
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.6.2
>            Reporter: philippe le berre
>
> For instance,
> public class Alice {
> private String comment;
> private String name;
> public Alice();
> public Alice(String comment)  {this.comment = comment; }
> public String toString() { return "[name:"+name+", comment:"+comment+"]"; }
> }
> if invoking :
> client.setReturnType(new Class[] {  Alice[].class });
> Alice[] ar = (Alice[]) client.invokeBlocking(new Object[3]);
> Then the deserialised array contains object instantiated with calls to Alice(obj.toString()). If one removes the Alice(String s) constructor then the array is correct, Alice objects are instantiated properly.
> The root cause is the method ConvertToArbitraryObjectArray in org.apache.axis2.databinding.utils.ConverterUtil
> ---
>                        Array.set(returnArray, i, getObjectForClass(
>                                 baseArrayClass,
>                                 o.toString()));
> ---
> The one test that refers to this is testBigInteger in ConverterUtilTest, so I propose the following fix :
>       if (! ADBBean.class.isAssignableFrom(baseArrayClass) && 
>         		java.lang.Number.class.isAssignableFrom(baseArrayClass)) {
> The ConvertUtilTest is then ok, as well as any array of Alice !



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org