From b83d378cd0f3c178c8e54477dfdd65344d25e673 Mon Sep 17 00:00:00 2001 From: cheeseng Date: Fri, 5 Apr 2013 15:05:28 +0800 Subject: [PATCH] Changed ForkTests to call acceptorThread.join(), to make sure that acceptorThread is finished before Acceptor.result is called. --- main/actions/src/main/scala/sbt/ForkTests.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main/actions/src/main/scala/sbt/ForkTests.scala b/main/actions/src/main/scala/sbt/ForkTests.scala index c18b76283..17bf0a32e 100755 --- a/main/actions/src/main/scala/sbt/ForkTests.scala +++ b/main/actions/src/main/scala/sbt/ForkTests.scala @@ -72,7 +72,8 @@ private[sbt] object ForkTests { try { testListeners.foreach(_.doInit()) - new Thread(Acceptor).start() + val acceptorThread = new Thread(Acceptor) + acceptorThread.start() val fullCp = classpath ++: Seq(IO.classLocationFile[ForkMain], IO.classLocationFile[Framework]) val options = Seq("-classpath", fullCp mkString File.pathSeparator, classOf[ForkMain].getCanonicalName, server.getLocalPort.toString) @@ -80,8 +81,11 @@ private[sbt] object ForkTests { val result = if (ec != 0) (TestResult.Error, Map("Running java with options " + options.mkString(" ") + " failed with exit code " + ec -> TestResult.Error)) - else + else { + // Need to wait acceptor thread to finish its business + acceptorThread.join() Acceptor.result + } testListeners.foreach(_.doComplete(result._1)) result } finally {