From 081f6bac077243fd3d51514d52b80c7a478f9554 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 15 Aug 2014 15:20:50 -0400 Subject: [PATCH] Ignore "java -version" IOException when launching servers process.start and reading from the stderr stream could in theory throw IOException, we want to return None then rather than crashing. --- launch/src/main/scala/xsbt/boot/ServerApplication.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/launch/src/main/scala/xsbt/boot/ServerApplication.scala b/launch/src/main/scala/xsbt/boot/ServerApplication.scala index bc0be9780..c8123bcb9 100644 --- a/launch/src/main/scala/xsbt/boot/ServerApplication.scala +++ b/launch/src/main/scala/xsbt/boot/ServerApplication.scala @@ -209,7 +209,7 @@ object ServerLauncher { } // None = couldn't figure it out - def javaIsAbove(currentDirectory: File, version: Int): Option[Boolean] = { + def javaIsAbove(currentDirectory: File, version: Int): Option[Boolean] = try { val pb = new java.lang.ProcessBuilder() // hopefully "java -version" is a lot faster than booting the full JVM. // not sure how else we can do this. @@ -231,6 +231,11 @@ object ServerLauncher { process.destroy() try { process.waitFor() } catch { case NonFatal(_) => } } + } catch { + case e: IOException => + // both process.start and reading the output streams can throw IOException. + // all OS exceptions from process.start are supposed to be IOException. + None } def serverJvmArgs(currentDirectory: File, serverConfig: ServerConfiguration): List[String] =