RFR 8015008: Primitive iterator over empty sequence, null consumer: forEachRemaining methods do not throw NPE (original) (raw)

Paul Sandoz paul.sandoz at oracle.com
Wed May 29 11:35:00 UTC 2013


Hi,

Please review these changes to j.u.PrimitiveIterator to ensure the default forEachRemaining methods consistently throw an NPE when the consumer is null.

I almost produced a webrev for this, but i thought it was just about acceptable size-wise and i hope easy to review in textual form. If this is considered impolite, awkward to review etc please say so and i will produce a webrev.

Paul.

HG changeset patch

User psandoz

Date 1369825083 -7200

Node ID 7ded996200218791c885c0aae4c474066101c7bd

Parent bfdc1ed75460c9e6869827cf9acabd4b1a5e9d29

8015008: Primitive iterator over empty sequence, null consumer: forEachRemaining methods do not throw NPE Reviewed-by:

diff -r bfdc1ed75460 -r 7ded99620021 src/share/classes/java/util/PrimitiveIterator.java --- a/src/share/classes/java/util/PrimitiveIterator.java Wed May 29 12:58:02 2013 +0200 +++ b/src/share/classes/java/util/PrimitiveIterator.java Wed May 29 12:58:03 2013 +0200 @@ -91,6 +91,7 @@ * @throws NullPointerException if the specified action is null */ default void forEachRemaining(IntConsumer action) {

@@ -123,6 +124,8 @@ forEachRemaining((IntConsumer) action); } else {

@@ -162,6 +165,7 @@ * @throws NullPointerException if the specified action is null */ default void forEachRemaining(LongConsumer action) {

@@ -194,6 +198,8 @@ forEachRemaining((LongConsumer) action); } else {

@@ -232,6 +238,7 @@ * @throws NullPointerException if the specified action is null */ default void forEachRemaining(DoubleConsumer action) {

@@ -265,6 +272,8 @@ forEachRemaining((DoubleConsumer) action); } else {

diff -r bfdc1ed75460 -r 7ded99620021 test/java/util/Iterator/PrimitiveIteratorDefaults.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/Iterator/PrimitiveIteratorDefaults.java Wed May 29 12:58:03 2013 +0200 @@ -0,0 +1,115 @@ +/*



More information about the core-libs-dev mailing list