Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-266

Issue with MultiKey when serialized/deserialized via RMI

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.2.2, 4.0-alpha1, 4.0
    • Component/s: KeyValue
    • Labels:
      None

      Description

      This is because the hash code of MultiKey is calculated only once.

      So if the MultiKey is deserialized in an other jvm, and if one at least of the subkeys defines its hash code with System.identityHashCode() (for example all the enums does), then the hash code of the MultiKey is no longer valid, and you can't retreive the key in your Map.

      I fixed it by making the cached hash code field transient, and by recalculating the hash code during deserialization.

        Attachments

        1. TestCollections266.java
          2 kB
          Henri Yandell
        2. TestCollections266.java
          3 kB
          Julien Buret
        3. TestCollections266.java
          2 kB
          Henri Yandell
        4. MultiKey.java
          9 kB
          Julien Buret
        5. collections-testcase-266.diff
          3 kB
          Joerg Schaible
        6. COLLECTIONS-266.patch
          2 kB
          Henri Yandell
        7. CC-266-final.patch
          4 kB
          Joerg Schaible

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jburet Julien Buret
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: