On Thu, May 6, 2010 at 15:58, David Holmes <david.hol...@oracle.com> wrote: >> Fix: >> >> http://cr.openjdk.java.net/~martin/webrevs/openjdk7/PriorityQueueConstructor/ > > I'm not sure this is necessarily the right fix. It seems to me that > incidental nulls will be caught in many/most cases by the sorting code for > collections assumed to contain Comparable's.
The comparator might accept nulls. But even if it doesn't, it is possible to create a "corrupted" PQ using the PQ(collection) constructor, and we don't allow that sort of thing in java.util. > And we don't need to check when > filling from an existing PriorityQueue. Strictly speaking, the source PriorityQueue might be a subclass that has been modified to accept nulls. But yes, we could have a version of the fix that only checks for nulls if the source is not a PQ. > So is it only the case for filling > from a SortedSet that needs the explicit null check? The source can be an arbitrary Collection. Martin > David >