src/share/classes/java/util/stream/IntPipeline.java
Print this page
rev 7633 : 8017513: Support for closeable streams
Reviewed-by:
Contributed-by: brian.goetz@oracle.com
*** 299,313 ****
downstream.begin(-1);
}
@Override
public void accept(int t) {
// We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
- IntStream result = mapper.apply(t);
if (result != null)
result.sequential().forEach(i -> downstream.accept(i));
}
};
}
};
}
--- 299,314 ----
downstream.begin(-1);
}
@Override
public void accept(int t) {
+ try (IntStream result = mapper.apply(t)) {
// 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(i -> downstream.accept(i));
}
+ }
};
}
};
}