summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/io
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2015-09-24 21:56:16 -0400
committerSeth Tisue <seth@tisue.net>2015-09-25 11:36:09 -0400
commitefece9fdb5c268d5a1af5b44cdac198c19eaff87 (patch)
tree69465ad3c0b24be67b410420e6ecb344eded5112 /src/reflect/scala/reflect/io
parent687397335843f4c21a9bccb8f01cc257320db08f (diff)
downloadscala-efece9fdb5c268d5a1af5b44cdac198c19eaff87.tar.gz
scala-efece9fdb5c268d5a1af5b44cdac198c19eaff87.tar.bz2
scala-efece9fdb5c268d5a1af5b44cdac198c19eaff87.zip
add comments warning of InputStream leaks in scala.io.reflect
Diffstat (limited to 'src/reflect/scala/reflect/io')
-rw-r--r--src/reflect/scala/reflect/io/Streamable.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala
index aa47947672..99a14d1fb0 100644
--- a/src/reflect/scala/reflect/io/Streamable.scala
+++ b/src/reflect/scala/reflect/io/Streamable.scala
@@ -27,6 +27,10 @@ object Streamable {
* efficient method implementations.
*
* ''Note: This library is considered experimental and should not be used unless you know what you are doing.''
+ *
+ * Note that this code was not written with resource management in mind.
+ * Several methods (such as `chars` and `lines`) create InputStreams they
+ * don't close
*/
trait Bytes {
def inputStream(): InputStream
@@ -82,9 +86,13 @@ object Streamable {
*/
def creationCodec: Codec = implicitly[Codec]
+ /** Caller is responsible for closing the returned BufferedSource. */
def chars(codec: Codec): BufferedSource = Source.fromInputStream(inputStream())(codec)
+ /** Beware! Leaks an InputStream which will not be closed until it gets finalized. */
def lines(): Iterator[String] = lines(creationCodec)
+
+ /** Beware! Leaks an InputStream which will not be closed until it gets finalized. */
def lines(codec: Codec): Iterator[String] = chars(codec).getLines()
/** Obtains an InputStreamReader wrapped around a FileInputStream.