RFR: 8292317: Missing null check for Iterator.forEachRemaining implementations [v2]
Jaikiran Pai
jpai at openjdk.org
Fri Nov 18 01:11:21 UTC 2022
On Thu, 17 Nov 2022 20:15:55 GMT, Marcono1234 <duke at openjdk.org> wrote:
>> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>>
>> review suggestion - simplify test
>
> src/java.base/share/classes/java/util/Collections.java line 1718:
>
>> 1716: public void forEachRemaining(Consumer<? super Map.Entry<K, V>> action) {
>> 1717: Objects.requireNonNull(action);
>> 1718: i.forEachRemaining(entryConsumer(action));
>
> As pointed out in the bug report description, it might be better to add the `null` check to `entryConsumer`. That would avoid code duplication for the `null` checks for all the current callers of `entryConsumer`.
>
> (This comment only applies here; for `CheckedEntrySet` below this does not work because it does not call `entryConsumer`.)
Hello @Marcono1234, I prefer doing it earliest in the top level method (which specifies the contract) instead of doing it in an internal method that this method calls.
-------------
PR: https://git.openjdk.org/jdk/pull/11154
More information about the core-libs-dev
mailing list