RFR-8148838: Stream.flatMap(...).spliterator() cannot properly split after tryAdvance()

Paul Sandoz paul.sandoz at oracle.com
Tue Feb 2 15:10:30 UTC 2016

Hi Tagir,

Nice find.

My inclination is to keep this simple and not support splitting after partial traversal.

Sometimes splitting after partial traversal might be more complex not support (e.g. ArrayList). In other cases it’s more complex to support and in such cases i would argue it is not worth it since this kind of functionality is an edge case.

Testing wise you are right to be concerned about the increase in test execution time. The lack of flatMap is definitely an omission. In this case I think it is ok to replace map with flatMap, as both result in stuff going into the holding buffer, and we can use the smaller data sets, e.g. "StreamTestData<Integer>.small”, that were recently added.


> On 2 Feb 2016, at 09:24, Tagir F. Valeev <amaembo at gmail.com> wrote:
> Please review and sponsor this fix:
> https://bugs.openjdk.java.net/browse/JDK-8148838
> http://cr.openjdk.java.net/~tvaleev/webrev/8148838/r1/
> When buffer traversal is already started, and split is requested, then
> the existing buffer should be carefully transferred to the prefix
> part.
> The only problem I see here is the testing time. Due to
> permuteFunctions() call it increases significantly what I added the
> flatMap() test. If this becomes an issue, I can write new simple test
> which tests flatMap() only (without permutations with other
> intermediate operations).
> With best regards,
> Tagir Valeev.

More information about the core-libs-dev mailing list