RFR: JDK-8068427 Hashtable deserialization reconstitutes table with wrong capacity

Martin Buchholz martinrb at google.com
Mon Jan 5 01:43:26 UTC 2015


Looks good.  Not surprising no one ever noticed, since the code is
intentionally trying to reduce the number of buckets.  I would encapsulate
serialization mechanics in a separate serialClone method, as done elsewhere
e.g.


    @SuppressWarnings("unchecked")
    private static <T> T serialClone(T o) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(o);
        oos.flush();
        oos.close();
        ByteArrayInputStream bin =
            new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bin);
            return (T) ois.readObject();
    }


On Sun, Jan 4, 2015 at 9:58 AM, Peter Levart <peter.levart at gmail.com> wrote:

> Hi,
>
> While investigating the following issue:
>
>     https://bugs.openjdk.java.net/browse/JDK-8029891
>
> I noticed there's a bug in deserialization code of java.util.Hashtable
> (from day one probably):
>
>     https://bugs.openjdk.java.net/browse/JDK-8068427
>
> The fix is a trivial one-character replacement: '*' -> '/', but I also
> corrected some untruthful comments in the neighbourhood (which might have
> been true from day one, but are not any more):
>
> http://cr.openjdk.java.net/~plevart/jdk9-dev/Hashtable.8068427/webrev.01/
>
>
> Regards, Peter
>
>



More information about the core-libs-dev mailing list