axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Jordahl <t...@macromedia.com>
Subject RE: [PATCH] RE: Is this a bug in serialization?
Date Wed, 03 Jul 2002 18:54:04 GMT

With a test!  Thanks John.

Watch for the commit shortly.


--
Tom Jordahl
Macromedia


-----Original Message-----
From: John Gregg [mailto:john.gregg@techarch.com]
Sent: Wednesday, July 03, 2002 2:29 PM
To: axis-dev@xml.apache.org
Subject: [PATCH] RE: Is this a bug in serialization?


Here's fix to the serialization problem Naresh had.

To summarize the problem, in cases where two distinct objects for which
equals() returned true and hashCode() returned the same value, only one
"instance" would appear in the serialized output.  The correct result was
for 2 instances to appear in the output (2 objects in, 2 objects out.)

The cause was the reliance on the instances' equals() and hashCode()
methods.  If SerializationContextImpl.doMultiRefs == true, then serialized
objects were cached in a HashMap keyed by the object itself.  With that
particular caching mechanism, objects that were equal but not identical were
incorrectly treated as the same object.  The fix was simply to key the map
by System.identityHashCode(o).

The test class I'm providing here exposes the problem in testEquality3().

Another random thought:

Someone added a secondLevelObjects instance variable to
SerializationContextImpl and populates it under certain conditions but never
uses it otherwise.  It looks like someone just got sidetracked and didn't
finish his thought.

john



-----Original Message-----
From: axis-dev-return-11064-john.gregg=techarch.com@xml.apache.org
[mailto:axis-dev-return-11064-john.gregg=techarch.com@xml.apache.org]On
Behalf Of John Gregg
Sent: Wednesday, July 03, 2002 9:26 AM
To: axis-dev@xml.apache.org
Subject: RE: Is this a bug in serialization?


I'm working on a fix right now.  I think fixing it is easy-- writing the
test is a little more work.

john


Mime
View raw message