commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joerg Schaible (JIRA)" <>
Subject [jira] Commented: (COLLECTIONS-266) Issue with MultiKey when serialized/deserialized via RMI
Date Wed, 19 Sep 2007 08:22:43 GMT


Joerg Schaible commented on COLLECTIONS-266:

1/ You cannot fix natural hash codes in general. It works for Enums since they use always
the same instance in the same VM.
2/ I've added a test case that does something similar ... I missed Julian's TC, but yes, that
test would be sufficient also
3/ I had complaints against adding the "transient". I can run the TestAllPackages suite though
and I assume (although I did not find where) that it also contains compatibility tests for
serialization, since there are such objects in the data/test directory. This would prove Stephen's
comment right that Java serialization can deal with the situation  - at least in one direction.
But I doubt it will work in the other direction i.e. an old version of CC can read such a
serialized object. Therefore I'd simply remove the final. And IMHO it matters if the serialVersionUID
changes, since the current code is only broken for a special use case ;-)

> Issue with MultiKey when serialized/deserialized via RMI
> --------------------------------------------------------
>                 Key: COLLECTIONS-266
>                 URL:
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: KeyValue
>    Affects Versions: 3.2
>            Reporter: Julien Buret
>            Priority: Minor
>             Fix For: 3.3
>         Attachments: COLLECTIONS-266.patch, collections-testcase-266.diff,,,,
> 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. 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message