[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-lambda-dev
Subject:    uniqueElements().iterator() returns broken iterator
From:       paul.sandoz () oracle ! com (Paul Sandoz)
Date:       2012-11-30 17:21:57
Message-ID: 753F15A2-8D9F-43B4-8E40-4641B6E7EFB4 () oracle ! com
[Download RAW message or body]

Thanks.

Note that the EG is still cogitating on what to be about nulls. Until agreement is \
reached this area is up for change.

However, i will fix things next week so nulls are not ignored and \
java.util.NoSuchElementException is not thrown on iteration.

Paul.


On Nov 30, 2012, at 5:28 PM, Georgiy Rakov <georgiy.rakov at oracle.com> wrote:

> Hello again,
> 
> when executing uniqueElements() on stream consisting of null elements broken \
> iterator is returned. 
> Consider following code.
> 
> import java.util.ArrayList;
> import java.util.Arrays;
> import java.util.Iterator;
> import java.util.List;
> 
> public class UniqueElementsIssue3 {
> public static void main(String arg[]) {
> Iterator<Integer> it = Arrays.asStream(new Integer[]{null,
> null, null}).uniqueElements().iterator();
> Integer i = null;
> List<Object> result1 = new ArrayList<>();
> while (it.hasNext()) {
> i = it.next();
> result1.add(i);
> }
> System.out.println("resul1=" +
> Arrays.toString(result1.toArray()));
> }
> }
> 
> This code throws the exception with following stacktrace.
> 
> Exception in thread "main" java.util.NoSuchElementException
> at java.util.streams.ops.UniqOp$2.next(UniqOp.java:118)
> at UniqueElementsIssue3.main(UniqueElementsIssue3.java:19)
> 
> The reason is obvious: it.next() fails while it.hasNext() returns true.
> This occurs for stream in parallel mode as well.
> 
> Could you please tell when we could expect this bug to be fixed (and others on \
> uniqueElements - see two my previous letters). 
> Source code is attached for your convenience.
> 
> Thanks,
> Georgiy,
> <UniqueElementsIssue3.java>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic