Some small issues with the stream library
Kasper Nielsen
kasperni at gmail.com
Thu Apr 17 13:13:51 UTC 2014
Hi,
I'm trying to build a small test suite for for a custom stream
implementation I'm making.
And I found a couple of small issues with java.util.stream.Stream. Nothing
major but might be worth fixing
1)
There are couple of places where null checks are missing
*Stream.close
Int/Double/LongStream.flatmap
Int/Double/LongStream.collect(x,y, 3rd) 3rd argument not being checked
2)
These methods does throw NPE but they consume the stream before throwing.
I like to think of null parameter checks as side-effect free.
Stream.forEach
Stream.forEachOrdered
Stream.sorted
Stream.toArray
3)
LongStream.Average does not always work as intended with high long values
Arrays.*asList*(Long.*MAX_VALUE* - 1000L, Long.*MAX_VALUE* -
1000L).stream().mapToLong(e -> e).average().getAsDouble; return -1001.0
Same thing with SummaryStatistics
Cheers
Kasper
More information about the lambda-libs-spec-observers
mailing list