CDV ❯ HashMap Serialization can have unresolved references
-
Bug
-
Status: Closed
-
2 Major
-
Resolution: Fixed
-
-
-
hhuynh
-
Reporter: sbale
-
September 16, 2008
-
0
-
Watchers: 0
-
November 03, 2008
-
September 19, 2008
Description
Similarly to CDV-244, we’ve found that HashMap (prior to JDK 1.6) serialization defeats TC instrumentation, which can lead to a serialized HashMap with unresolved references.
More specifically, the serialized HashMap can contain Terracotta ObjectID’s rather than the expected values, leading to a ClassCastException. This is because the writeObject() method of HashMap (prior to JDK 1.6) calls private method entrySet0(), which we do not instrument, rather than public method entrySet(), which we do instrument.
We already have this bug reproduced in a system test and I am working on it.
(Tim found that this was apparently a bug that was fixed in JDK 1.6 - see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6280967 )
Comments
Scott Bale 2008-09-16
Scott Bale 2008-09-16
Last night I found that the writeObject() method of HashMap uses a private non-instrumented entrySet0() method to retrieve entries, rather than the public, Terracotta-instrumented entrySet method.
Today, Tim found this is only true in source code of JDK 1.4 and 1.6 but NOT JDK 1.5! That’s not a misprint.
I checked with Himadri, and sure enough he was using JDK 1.6. I have been using JDK 1.5, which explains why I never saw this ClassCastException before.
Also, the system test I wrote passes (predictably) with JDK 1.5 and fails (predictably) with JDK 1.4. So I think we’re on the right track.
Scott Bale 2008-09-19
fixed in trunk (10114, 10118, 10142) and 2.7 branch (10155)
Hung Huynh 2008-11-03
test existed
similar serialization bug, affecting Exam caching