diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-03-11 20:22:04 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-03-11 20:22:04 -0700 |
commit | a67b62698d7a8768c6fb17af127f3061f59649f7 (patch) | |
tree | 2ad50d0c4fcf55a612e46d658b390ecb25e3efbb /src/reflect | |
parent | 1b6297f642877dcc7edcd704a5d3cf99a12e54b8 (diff) | |
download | scala-a67b62698d7a8768c6fb17af127f3061f59649f7.tar.gz scala-a67b62698d7a8768c6fb17af127f3061f59649f7.tar.bz2 scala-a67b62698d7a8768c6fb17af127f3061f59649f7.zip |
Close after slurping (fixes SI-7244)
Since slurp by definition is the noise made by the straw when
the cup is empty and all milk shake is consumed, we can safely
close after slurping.
Use case was deleting a test artifact on Windows.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/io/Streamable.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala index 6184c6776a..1d51ad7f54 100644 --- a/src/reflect/scala/reflect/io/Streamable.scala +++ b/src/reflect/scala/reflect/io/Streamable.scala @@ -106,7 +106,10 @@ object Streamable { /** Convenience function to import entire file into a String. */ def slurp(): String = slurp(creationCodec) - def slurp(codec: Codec) = chars(codec).mkString + def slurp(codec: Codec) = { + val src = chars(codec) + try src.mkString finally src.close() // Always Be Closing + } } /** Call a function on something Closeable, finally closing it. */ |