Issue Details (XML | Word | Printable)

Key: COLLECTIONS-266
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Julien Buret
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Commons Collections

Issue with MultiKey when serialized/deserialized via RMI

Created: 11/Sep/07 09:02 PM   Updated: 30/May/08 06:24 AM
Return to search
Component/s: KeyValue
Affects Version/s: 3.2
Fix Version/s: 4.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works CC-266-final.patch 2008-05-13 11:01 AM Joerg Schaible 4 kB
Text File Licensed for inclusion in ASF works COLLECTIONS-266.patch 2007-09-12 05:21 PM Henri Yandell 2 kB
File Licensed for inclusion in ASF works collections-testcase-266.diff 2007-09-19 08:10 AM Joerg Schaible 3 kB
Java Source File Licensed for inclusion in ASF works MultiKey.java 2007-09-11 09:04 PM Julien Buret 9 kB
Java Source File Licensed for inclusion in ASF works TestCollections266.java 2007-09-13 11:16 PM Henri Yandell 2 kB
Java Source File Licensed for inclusion in ASF works TestCollections266.java 2007-09-13 07:56 AM Julien Buret 3 kB
Java Source File Licensed for inclusion in ASF works TestCollections266.java 2007-09-12 11:44 PM Henri Yandell 2 kB

Resolution Date: 30/May/08 06:24 AM


 Description  « Hide
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.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.