Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 36505 invoked from network); 14 Sep 2007 08:53:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Sep 2007 08:53:57 -0000 Received: (qmail 79655 invoked by uid 500); 14 Sep 2007 08:53:49 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 79513 invoked by uid 500); 14 Sep 2007 08:53:48 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 79504 invoked by uid 99); 14 Sep 2007 08:53:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 01:53:48 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Sep 2007 08:55:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 90C0F714201 for ; Fri, 14 Sep 2007 01:53:32 -0700 (PDT) Message-ID: <15386711.1189760012590.JavaMail.jira@brutus> Date: Fri, 14 Sep 2007 01:53:32 -0700 (PDT) From: "Joerg Schaible (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (COLLECTIONS-266) Issue with MultiKey when serialized/deserialized via RMI In-Reply-To: <20828754.1189544672037.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COLLECTIONS-266?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12527413 ]= =20 Joerg Schaible commented on COLLECTIONS-266: -------------------------------------------- Well, this problem with Enums has a history: - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6421053 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6373406 However, in the end you're right and the hashCode should not have been stor= ed in the MultiKey in this way. We might solve this by adding a readResolve= method: private Object readResolve() { return new MultiKey(keys, false); } that way we create a new MultiKey with the correct hashCode. Your solution = with the transient member will break the serialization compatibility, since= you changed the binary layout. Therefore the hashCode member *must* be ser= ialized - otherwise you have to change also the serialVersionUID. But with = a private calculateHashCode method and setting the hashCode member not to f= inal, we can implement readResolve different: private Object readResolve() { calculateHashCode(); return this; } But our clirr report may still choke about the final. - J=C3=B6rg > Issue with MultiKey when serialized/deserialized via RMI > -------------------------------------------------------- > > Key: COLLECTIONS-266 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-26= 6 > 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, MultiKey.java, TestCollection= s266.java, TestCollections266.java, TestCollections266.java > > > This is because the hash code of MultiKey is calculated only once.=20 > So if the MultiKey is deserialized in an other jvm, and if one at least o= f the subkeys defines its hash code with System.identityHashCode() (for exa= mple all the enums does), then the hash code of the MultiKey is no longer v= alid, and you can't retreive the key in your Map. > I fixed it by making the cached hash code field transient, and by recalcu= lating the hash code during deserialization.=20 --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.