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,15 +261,16 @@
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
- Stream<? extends R> result = mapper.apply(u);
if (result != null)
result.sequential().forEach(downstream);
}
+ }
};
}
};
}
@@ -288,15 +289,16 @@
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
- IntStream result = mapper.apply(u);
if (result != null)
result.sequential().forEach(downstreamAsInt);
}
+ }
};
}
};
}
@@ -315,15 +317,16 @@
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
- DoubleStream result = mapper.apply(u);
if (result != null)
result.sequential().forEach(downstreamAsDouble);
}
+ }
};
}
};
}
@@ -342,15 +345,16 @@
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
- LongStream result = mapper.apply(u);
if (result != null)
result.sequential().forEach(downstreamAsLong);
}
+ }
};
}
};
}