src/share/classes/java/util/stream/LongStream.java
Print this page
rev 7627 : 8015315: Stream.concat methods
Reviewed-by: psandoz
Contributed-by: brian.goetz@oracle.com, henry.jen@oracle.com
rev 7630 : 8019395: Consolidate StreamSupport.{stream,parallelStream} into a single method
Reviewed-by: henryjen
rev 7631 : 8020062: Nest StreamBuilder interfaces inside relevant Stream interfaces
Reviewed-by: psandoz
Contributed-by: brian goetz <brian.goetz@oracle.com>
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
@@ -810,11 +810,12 @@
/**
* Creates a lazy concatenated {@code LongStream} whose elements are all the
* elements of a first {@code LongStream} succeeded by all the elements of the
* second {@code LongStream}. The resulting stream is ordered if both
* of the input streams are ordered, and parallel if either of the input
- * streams is parallel.
+ * streams is parallel. When the resulting stream is closed, the close
+ * handlers for both input streams is invoked.
*
* @param a the first stream
* @param b the second stream to concatenate on to end of the first stream
* @return the concatenation of the two streams
*/
@@ -822,11 +823,12 @@
Objects.requireNonNull(a);
Objects.requireNonNull(b);
Spliterator.OfLong split = new Streams.ConcatSpliterator.OfLong(
a.spliterator(), b.spliterator());
- return StreamSupport.longStream(split, a.isParallel() || b.isParallel());
+ LongStream stream = StreamSupport.longStream(split, a.isParallel() || b.isParallel());
+ return stream.onClose(Streams.composedClose(a, b));
}
/**
* A mutable builder for a {@code LongStream}.
*