Identifying resource-using streams
Erik Costlow
erik.costlow at oracle.com
Thu Apr 17 22:51:03 UTC 2014
I was looking through the javadoc of different items and noticed an area where some machine-parseable documentation (like an annotation) may help developers produce better applications.
NIO's Files.lines returns a Stream<String> that uses a filesystem resource. This is correctly listed in the javadoc which says, "If timely disposal of file system resources is required, the try-with-resources construct should be used" and the Stream api itself says "Generally, only streams whose source is an IO channel (such as those returned by Files.lines(Path, Charset)) will require closing."
Given that all streams are AutoCloseable but only some merit user attention, has consideration been given towards indicating (to automated tools) which streams the users should close?
Or was this question covered already in http://mail.openjdk.java.net/pipermail/lambda-dev/2013-July/010394.html ?
More information about the lambda-dev
mailing list