JDK-8268483 : Guidance on stream limitations in laziness and termination
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.stream
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2021-06-09
  • Updated: 2024-04-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
Streams generally produce elements lazily and avoid production of excess elements when there are short circuiting operations. However, for less common cases laziness is not possible There is a tradeoff between implementation complexity and laziness.

Problematic cases arise for the following:
1. use of an "escape hatch" iterator or spliterator terminal operation 
2. use of nested flatMap operations

It would be beneficial to add some guidance to the stream package documentation.

Comments
Point no 2 will be addressed by me fixing #8196106
09-04-2024