On Wed, 8 Jul 2026 14:15:53 GMT, Viktor Klang <[email protected]> wrote:

>> Daisuke Yamazaki has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Make heapify static
>
> src/java.base/share/classes/java/util/PriorityQueue.java line 312:
> 
>> 310:         // If a comparator is used, null must be rejected before it is
>> 311:         // passed to the comparator.
>> 312:         if (len == 1 || cmp != null)
> 
> What's the reason for the `len == 1`-check (add comment)

Thanks, I see the issue and updated the comment.

I have updated the comment to describe both sides of the condition.
The `len == 1` case is needed because a single element is not examined by 
`heapify()`, and the comparator case is needed because a comparator may permit 
`null`.

Does this capture the reason for the explicit `null` check?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/31701#discussion_r3546251551

Reply via email to