XML-RPC
  1. XML-RPC
  2. XMLRPC-127

Serialization/deserialization of Map does not retain correct datatype

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: None
    • Component/s: Source
    • Labels:
      None

      Description

      Believe that this is quite severe bug unless I did something very wrong.
      When sending/rretrieving a Map over XMLRPC the datatype is not correct. I've only checked for the keys, but the error might exist for the values as well.

      Provided is a simple unit test to illustrate the bug. To reproduce run the unit tests in SerializationTest.
      It has two test methods:

      1) one that calls a static method and
      2) and another that calls a method over XMLRPC which in turns call the same static method

      The latter fails with a ClassCastException. Instead of the key being the expected Integer it is a String.

      >From Console:
      [...]
      key: 21
      value: twentyone
      21 -> 'twentyone'
      key: 1
      value: one
      1 -> 'one'
      [...]
      key: 21

      >From Debug -> Variables (in Eclipse):

      entry HashMap$Entry<K,V> (id=13)
      key "21"
      count 2
      hash 1599
      offset 0
      value char[2] (id=27)
      value "twentyone"
      count 9
      hash 0
      offset 0
      value char[9] (id=29)

      As you can see 21 is a char[2] and not an integer as expected.

      1. test.zip
        8 kB
        Jimisola Laursen

        Activity

        Hide
        Jochen Wiedmann added a comment -

        Is there any attachment missing? What is "SerializationTest"?

        Show
        Jochen Wiedmann added a comment - Is there any attachment missing? What is "SerializationTest"?
        Hide
        Jimisola Laursen added a comment -

        Contains unit test to reveal possible bug.

        Show
        Jimisola Laursen added a comment - Contains unit test to reveal possible bug.
        Hide
        Jochen Wiedmann added a comment -

        When running your example, I receive the following error code:

        Failed to invoke method setMap in class xmlrpctest.TestRPCImpl:
        java.lang.String cannot be cast to java.lang.Integer

        I find this quite understandable, because map keys can only be string, at least according to the XML-RPC spec. In other words, parameters like Map<Integer,...> cannot work.

        Show
        Jochen Wiedmann added a comment - When running your example, I receive the following error code: Failed to invoke method setMap in class xmlrpctest.TestRPCImpl: java.lang.String cannot be cast to java.lang.Integer I find this quite understandable, because map keys can only be string, at least according to the XML-RPC spec. In other words, parameters like Map<Integer,...> cannot work.
        Hide
        Jimisola Laursen added a comment -

        Jochen,

        You should run the unit test (it calls the getMap method) as specified in the original description.
        The TestRPCImpl was just my class for testing out the behaviour and I kept it for reference.

        It might be that map keys can only be strings according to the XML-RPC spec, but when extensions are enabled I honestly expect any Map (no matter what datatype keys are) to be handled properly.

        Show
        Jimisola Laursen added a comment - Jochen, You should run the unit test (it calls the getMap method) as specified in the original description. The TestRPCImpl was just my class for testing out the behaviour and I kept it for reference. It might be that map keys can only be strings according to the XML-RPC spec, but when extensions are enabled I honestly expect any Map (no matter what datatype keys are) to be handled properly.
        Hide
        Jochen Wiedmann added a comment -

        Your wish is my command. Added in the trunk. Please let me know, whether we may close the issue.

        Show
        Jochen Wiedmann added a comment - Your wish is my command. Added in the trunk. Please let me know, whether we may close the issue.
        Hide
        Jimisola Laursen added a comment -

        Thank you! Does the current snapshot include this fix?

        Show
        Jimisola Laursen added a comment - Thank you! Does the current snapshot include this fix?
        Hide
        Jochen Wiedmann added a comment -

        Yes, I have deployed a current snapshot.

        Show
        Jochen Wiedmann added a comment - Yes, I have deployed a current snapshot.
        Hide
        Jimisola Laursen added a comment -

        It works. Thank you.

        Show
        Jimisola Laursen added a comment - It works. Thank you.
        Hide
        Jochen Wiedmann added a comment -

        Closing issues which have been released.

        Show
        Jochen Wiedmann added a comment - Closing issues which have been released.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jimisola Laursen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development