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

Issue with MultiKey when serialized/deserialized via RMI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2
    • 3.2.2, 4.0-alpha1, 4.0
    • KeyValue
    • 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. CC-266-final.patch
          4 kB
          Joerg Schaible
        2. COLLECTIONS-266.patch
          2 kB
          Henri Yandell
        3. collections-testcase-266.diff
          3 kB
          Joerg Schaible
        4. MultiKey.java
          9 kB
          Julien Buret
        5. TestCollections266.java
          2 kB
          Henri Yandell
        6. TestCollections266.java
          3 kB
          Julien Buret
        7. TestCollections266.java
          2 kB
          Henri Yandell

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: