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

Print this page
rev 7632 : 8015318: Extend Collector with 'finish' operation
Reviewed-by:
Contributed-by: brian.goetz@oracle.com
rev 7633 : 8017513: Support for closeable streams
Reviewed-by:
Contributed-by: brian.goetz@oracle.com

*** 261,275 **** 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); } }; } }; } --- 261,276 ---- 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); } + } }; } }; }
*** 288,302 **** 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); } }; } }; } --- 289,304 ---- 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); } + } }; } }; }
*** 315,329 **** 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); } }; } }; } --- 317,332 ---- 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); } + } }; } }; }
*** 342,356 **** 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); } }; } }; } --- 345,360 ---- 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); } + } }; } }; }