JDK-8229983 : flatMap still prevents short circuiting when using .iterator()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.stream
  • Affected Version: 11
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2019-08-21
  • Updated: 2024-04-04
  • Resolved: 2024-04-04
Related Reports
Duplicate :  
Relates :  
Description
flatMap was fixed in (8075939) so that it doesn't prevent short circuiting.
If you replace the test cases in the ticket with versions that use
.iterator().next() instead of .findFirst().get() then the problem
still happens. 

Email thread:
http://mail.openjdk.java.net/pipermail/core-libs-dev/2019-August/061868.html
Comments
The use of Stream::iterator() and Stream::spliterator() comes with certain drawbacks innate to converting a push-style stream to a pull-style API.
04-04-2024