-
Bug
-
Resolution: Not an Issue
-
P2
-
None
-
8
Consider the following code sample:
import java.util.Arrays;
import java.util.stream.LongStream;
import java.util.stream.StreamSupport;
public class StreamFromSpliterator {
public static void main(String[] args) {
getLongStream().noneMatch(e -> {
System.err.println(e);
return false;
});
System.err.println("---");
getLongStream().allMatch(e -> {
System.err.println(e);
return true;
});
System.err.println("---");
getLongStream().anyMatch(e -> {
System.err.println(e);
return false;
});
}
private static LongStream getLongStream() {
return StreamSupport.longStream(Arrays.spliterator(new long[]{1, 2, 3, 4}), true);
}
}
---------------------------------
The order of the consumed elements doesn't correspond the original.
The output will be like:
3
2
1
4
---
3
2
4
1
---
3
4
2
1
Plenty of JCK tests fail due to this issue:
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkLongs]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkLongs]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkDistinct]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkBoxed]
import java.util.Arrays;
import java.util.stream.LongStream;
import java.util.stream.StreamSupport;
public class StreamFromSpliterator {
public static void main(String[] args) {
getLongStream().noneMatch(e -> {
System.err.println(e);
return false;
});
System.err.println("---");
getLongStream().allMatch(e -> {
System.err.println(e);
return true;
});
System.err.println("---");
getLongStream().anyMatch(e -> {
System.err.println(e);
return false;
});
}
private static LongStream getLongStream() {
return StreamSupport.longStream(Arrays.spliterator(new long[]{1, 2, 3, 4}), true);
}
}
---------------------------------
The order of the consumed elements doesn't correspond the original.
The output will be like:
3
2
1
4
---
3
2
4
1
---
3
4
2
1
Plenty of JCK tests fail due to this issue:
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkLongs]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkLongs]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#IntParallelStreamFromCustomSpliterator[checkDistinct]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromCustomSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#DoubleParallelStreamFromCustomSpliterator[checkBoxed]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkDoubles]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkAnyMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkAllMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkNoneMatch]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkCollect2]
api/java_util/stream/StreamSupport/index.html#LongParallelStreamFromStandardSpliterator[checkBoxed]