Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5676

Deserialisation of array of obj fails if the class has a constructor(string s)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6.2
    • None
    • adb
    • None

    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 !

      Attachments

        1. ConverterUtil_patch.diff
          0.9 kB
          philippe le berre
        2. test_patch.diff
          1 kB
          philippe le berre

        Activity

          People

            Unassigned Unassigned
            p-leberre philippe le berre
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: