-
Sub-task
-
Resolution: Duplicate
-
P2
-
None
-
None
Consider the following code:
Stream<String> stream = new TreeMap<String, String>() {{
put("c", "c");
put("d", "d");
put("b", "b");
put("a", "a");
}}.values().stream();
Stream parallel = (Stream)stream.substream(1).parallel();
Iterator iterator = parallel.iterator();
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
The output will be
next = a
next = b
next = c
Exception in thread "main" java.util.NoSuchElementException
at java.util.Spliterators$1Adapter.next(Spliterators.java:688)
Which is not expected according to the specification of method Stream.substream():
* Returns a stream consisting of the remaining elements of this stream
* after indexing {@code startInclusive} elements into the stream.
The following JCK tests will fail due to this issue:
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapValueStream[checkSubstream]
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapValueStream[checkSubstream2]api/java_util/TreeMap/ValuesStream.html#ValuesStream[checkSubstream]
api/java_util/TreeMap/ValuesStream.html#ValuesStream[checkSubstream2]
api/java_util/TreeMap/ValuesParallelStream.html#ValuesParallelStream[checkSubstream]
api/java_util/TreeMap/ValuesParallelStream.html#ValuesParallelStream[checkSubstream2]
Stream<String> stream = new TreeMap<String, String>() {{
put("c", "c");
put("d", "d");
put("b", "b");
put("a", "a");
}}.values().stream();
Stream parallel = (Stream)stream.substream(1).parallel();
Iterator iterator = parallel.iterator();
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
System.out.println("next = " + iterator.next());
The output will be
next = a
next = b
next = c
Exception in thread "main" java.util.NoSuchElementException
at java.util.Spliterators$1Adapter.next(Spliterators.java:688)
Which is not expected according to the specification of method Stream.substream():
* Returns a stream consisting of the remaining elements of this stream
* after indexing {@code startInclusive} elements into the stream.
The following JCK tests will fail due to this issue:
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapValueStream[checkSubstream]
api/java_util/Collections/unmodifiable/index.html#UnmodifiableSortedMapValueStream[checkSubstream2]api/java_util/TreeMap/ValuesStream.html#ValuesStream[checkSubstream]
api/java_util/TreeMap/ValuesStream.html#ValuesStream[checkSubstream2]
api/java_util/TreeMap/ValuesParallelStream.html#ValuesParallelStream[checkSubstream]
api/java_util/TreeMap/ValuesParallelStream.html#ValuesParallelStream[checkSubstream2]
- duplicates
-
JDK-8020156 TreeMap.values().spliterator() does not report ORDERED
-
- Closed
-