diff options
author | Paul Phillips <paulp@improving.org> | 2010-04-09 19:07:40 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-04-09 19:07:40 +0000 |
commit | 56584c300fef40d3e2d8726b5e729553c3da4275 (patch) | |
tree | fc14712077cd77ce2d4bcc0d69a833d57d03e7cd | |
parent | eec07a42845fd2723eee911a4eeaf8a9c0d54044 (diff) | |
download | scala-56584c300fef40d3e2d8726b5e729553c3da4275.tar.gz scala-56584c300fef40d3e2d8726b5e729553c3da4275.tar.bz2 scala-56584c300fef40d3e2d8726b5e729553c3da4275.zip |
Some tweaks to process to see if it'll fix auxjvm.
-rw-r--r-- | src/compiler/scala/tools/nsc/io/File.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/io/Process.scala | 21 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/compiler/scala/tools/nsc/io/File.scala index 887bf4b55d..74bac3baf4 100644 --- a/src/compiler/scala/tools/nsc/io/File.scala +++ b/src/compiler/scala/tools/nsc/io/File.scala @@ -77,7 +77,7 @@ with Streamable.Chars { /** Obtains a OutputStream. */ def outputStream(append: Boolean = false) = new FileOutputStream(jfile, append) def bufferedOutput(append: Boolean = false) = new BufferedOutputStream(outputStream(append)) - def printStream(append: Boolean = false) = new PrintStream(bufferedOutput(append)) + def printStream(append: Boolean = false) = new PrintStream(outputStream(append), true) /** Obtains an OutputStreamWriter wrapped around a FileOutputStream. * This should behave like a less broken version of java.io.FileWriter, diff --git a/src/compiler/scala/tools/nsc/io/Process.scala b/src/compiler/scala/tools/nsc/io/Process.scala index 746c5f1a8d..698082d19e 100644 --- a/src/compiler/scala/tools/nsc/io/Process.scala +++ b/src/compiler/scala/tools/nsc/io/Process.scala @@ -6,6 +6,7 @@ package scala.tools.nsc package io import concurrent.ThreadRunner +import scala.annotation.tailrec import scala.util.Properties.{ isWin, isMac, lineSeparator } import scala.util.control.Exception.catching import java.lang.{ Process => JProcess, ProcessBuilder => JProcessBuilder } @@ -139,7 +140,7 @@ class Process(processCreator: () => JProcess) extends Iterable[String] { def waitFor() = process.waitFor() def destroy() = process.destroy() - def rerun() = new Process(processCreator) + def rerun() = new Process(processCreator) def slurp() = _out.slurp() def stdout = iterator @@ -148,26 +149,32 @@ class Process(processCreator: () => JProcess) extends Iterable[String] { lazy val stdin = new PrintWriter(_in, true) class StreamedConsumer(in: InputStream) extends Thread with Iterable[String] { - private val queue = new LinkedBlockingQueue[String] - private val reader = new BufferedReader(new InputStreamReader(in)) + private val queue = new LinkedBlockingQueue[String] + private val reader = new BufferedReader(new InputStreamReader(in)) - def slurp(): String = { + private def finish() { + // make sure this thread is complete, and close the process's stdin join() + _in.close() + } + + def slurp(): String = { + finish() queue.toArray map (_ + lineSeparator) mkString } def iterator = { - join() // make sure this thread is complete + finish() new Iterator[String] { val it = queue.iterator() def hasNext = it.hasNext def next = it.next } } - override def run() { + @tailrec override final def run() { reader.readLine match { case null => - in.close() + reader.close() case x => queue put x run() |