This is an automated email from the ASF dual-hosted git repository. rabbah pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push: new c5cf96e Revert "Use an asynchronous process runner to spawn container commands." (#2769) c5cf96e is described below commit c5cf96e399e6524f340cb21e1ccac67da0100c55 Author: Markus Thömmes <markusthoem...@me.com> AuthorDate: Tue Sep 19 01:56:40 2017 +0200 Revert "Use an asynchronous process runner to spawn container commands." (#2769) This reverts commit 6b0c03725b43d5454dc07ccc51318675b6b0905e. --- core/invoker/build.gradle | 2 - .../core/containerpool/docker/ProcessRunner.scala | 49 ++++++++-------------- 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/core/invoker/build.gradle b/core/invoker/build.gradle index d60ea40..14a9191 100644 --- a/core/invoker/build.gradle +++ b/core/invoker/build.gradle @@ -13,8 +13,6 @@ repositories { dependencies { compile "org.scala-lang:scala-library:${gradle.scala.version}" compile project(':common:scala') - - compile "com.zaxxer:nuprocess:1.1.2" } tasks.withType(ScalaCompile) { diff --git a/core/invoker/src/main/scala/whisk/core/containerpool/docker/ProcessRunner.scala b/core/invoker/src/main/scala/whisk/core/containerpool/docker/ProcessRunner.scala index 8540203..f8139b4 100644 --- a/core/invoker/src/main/scala/whisk/core/containerpool/docker/ProcessRunner.scala +++ b/core/invoker/src/main/scala/whisk/core/containerpool/docker/ProcessRunner.scala @@ -17,13 +17,11 @@ package whisk.core.containerpool.docker -import java.nio.ByteBuffer - -import akka.util.ByteString -import com.zaxxer.nuprocess.{NuAbstractProcessHandler, NuProcessBuilder} - -import scala.collection.JavaConverters._ -import scala.concurrent.{ExecutionContext, Future, Promise} +import scala.collection.mutable +import scala.concurrent.ExecutionContext +import scala.concurrent.Future +import scala.concurrent.blocking +import scala.sys.process._ trait ProcessRunner { @@ -37,30 +35,19 @@ trait ProcessRunner { * @param args command to be run including arguments * @return a future completing according to the command's exit code */ - protected def executeProcess(args: String*)(implicit ec: ExecutionContext): Future[String] = { - val promise = Promise[String]() - val pb: NuProcessBuilder = new NuProcessBuilder(args.asJava) - pb.setProcessListener(new NuAbstractProcessHandler { - var out = ByteString.empty - var err = ByteString.empty - - override def onExit(code: Int): Unit = code match { - case 0 => promise.success(out.utf8String.trim) - case _ => promise.failure(ProcessRunningException(code, out.utf8String.trim, err.utf8String.trim)) - } - - override def onStderr(buffer: ByteBuffer, closed: Boolean) = { - err = err ++ ByteString.fromByteBuffer(buffer) - } - - override def onStdout(buffer: ByteBuffer, closed: Boolean): Unit = { - out = out ++ ByteString.fromByteBuffer(buffer) - } - }) - - pb.start() - promise.future - } + protected def executeProcess(args: String*)(implicit ec: ExecutionContext) = + Future(blocking { + val out = new mutable.ListBuffer[String] + val err = new mutable.ListBuffer[String] + val exitCode = args ! ProcessLogger(o => out += o, e => err += e) + + (exitCode, out.mkString("\n"), err.mkString("\n")) + }).flatMap { + case (0, stdout, _) => + Future.successful(stdout) + case (code, stdout, stderr) => + Future.failed(ProcessRunningException(code, stdout, stderr)) + } } case class ProcessRunningException(exitCode: Int, stdout: String, stderr: String) -- To stop receiving notification emails like this one, please contact ['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].