Closed saffih closed 6 years ago
Unfortunately, this feature is not really easy to implement, because you can never really say if a stream is fully consumed. There's the Stream.iterator()
method, which allows for consuming a stream item by item and discarding it prior to full consumption. Also, intercepting an exception from within the stream pipeline isn't easy. Typcially, those exceptions would also trigger a stream being "finished".
See also:
Expected behavior and actual behavior:
Support autoclose specifically closing the underling stream once the stream is fully consumed (the provider of the stream protect it's side of the contract), the seq is handed over to a some other class that would not close it when it is fully consumed. Support deferred stream operations (for log, debug) and generation (extended seq).
Seq.of(1, 2, 3).onClose(()->{System.out.println("Done reading 1, 2, 3");}).autoclose() Updated Seq.java:597 added mthods: autoclose , append, prepend . (and appropriate unit tests.) https://github.com/saffih/jOOL/blob/seq-actions/jOOL-java-8/src/main/java/org/jooq/lambda/Seq.java
What your view with regard to that kind of extending seq ?
Thank Saffi
Steps to reproduce the problem:
Versions: