JDK 8 RFR 8016252: More defensive HashSet.readObject
Alan Bateman
Alan.Bateman at oracle.com
Mon Oct 7 20:31:30 UTC 2013
On 07/10/2013 18:40, Brian Burkhalter wrote:
> :
> I have posted an updated webrev here:
>
> http://cr.openjdk.java.net/~bpb/8016252.2/
>
> I don't know whether it is the correct way to go, but this version attempts to use the capacity, load factor, and size as read in, insofar as they appear reasonable.
>
This looks better.
The checks on loadFactor look okay.
I'm not so sure about capacity, a simple check if it is negative should
be sufficient.
For size then I don't think the Math.max has any real effect because the
loop don't do anything if size is negative You could just throw
IllegalObjectException if it is negative (as per the first patch) if you
really wanted to.
-Alan.
More information about the core-libs-dev
mailing list