PriorityQueue(collection) should throw NPE

David Holmes David.Holmes at oracle.com
Thu May 6 22:58:22 UTC 2010


Martin,

Martin Buchholz said the following on 05/07/10 08:24:
> This is a bug report with fix.
> (Chris, please file a bug)
> 
> Summary: PriorityQueue(collection) should throw NPE if collection
> contains a null
> 
> Description:
> PriorityQueue spec says:
> 
> "A priority queue does not permit {@code null} elements."
> 
> but the constructor taking a collection does not enforce that.
> 
> 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. And we don't need to 
check when filling from an existing PriorityQueue. So is it only the 
case for filling from a SortedSet that needs the explicit null check?

David



More information about the core-libs-dev mailing list