src/share/classes/java/util/stream/ReferencePipeline.java

Print this page
rev 7982 : 8017513: Support for closeable streams
8022237: j.u.s.BaseStream.onClose() has an issue in implementation or requires spec clarification
8022572: Same exception instances thrown from j.u.stream.Stream.onClose() handlers are not listed as suppressed
Summary: BaseStream implements AutoCloseable; Remove CloseableStream and DelegatingStream
Reviewed-by: alanb, mduigou, psandoz
Contributed-by: brian.goetz@oracle.com

*** 262,276 **** downstream.begin(-1); } @Override public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it - Stream<? extends R> result = mapper.apply(u); if (result != null) result.sequential().forEach(downstream); } }; } }; } --- 262,277 ---- downstream.begin(-1); } @Override public void accept(P_OUT u) { + try (Stream<? extends R> result = mapper.apply(u)) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it if (result != null) result.sequential().forEach(downstream); } + } }; } }; }
*** 289,303 **** downstream.begin(-1); } @Override public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it - IntStream result = mapper.apply(u); if (result != null) result.sequential().forEach(downstreamAsInt); } }; } }; } --- 290,305 ---- downstream.begin(-1); } @Override public void accept(P_OUT u) { + try (IntStream result = mapper.apply(u)) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it if (result != null) result.sequential().forEach(downstreamAsInt); } + } }; } }; }
*** 316,330 **** downstream.begin(-1); } @Override public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it - DoubleStream result = mapper.apply(u); if (result != null) result.sequential().forEach(downstreamAsDouble); } }; } }; } --- 318,333 ---- downstream.begin(-1); } @Override public void accept(P_OUT u) { + try (DoubleStream result = mapper.apply(u)) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it if (result != null) result.sequential().forEach(downstreamAsDouble); } + } }; } }; }
*** 343,357 **** downstream.begin(-1); } @Override public void accept(P_OUT u) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it - LongStream result = mapper.apply(u); if (result != null) result.sequential().forEach(downstreamAsLong); } }; } }; } --- 346,361 ---- downstream.begin(-1); } @Override public void accept(P_OUT u) { + try (LongStream result = mapper.apply(u)) { // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it if (result != null) result.sequential().forEach(downstreamAsLong); } + } }; } }; }