From 191737d35b6433192bd167970f5e98188ebb0348 Mon Sep 17 00:00:00 2001 From: James Roper Date: Mon, 4 Nov 2013 10:26:52 +1100 Subject: [PATCH] Log socket accept errors when forking tests If an exception is thrown when accepting a connection from a forked test agent, currently I'm seeing that all that happens is SBT hangs with no output. Thread dumps show that the main process is waiting for the agent to return, while the agent is waiting for the server to send it something. This change logs the exception, so that at least the error can be googled. It also cleans up the server socket. --- main/actions/src/main/scala/sbt/ForkTests.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main/actions/src/main/scala/sbt/ForkTests.scala b/main/actions/src/main/scala/sbt/ForkTests.scala index b9186b1fe..c6d318ee8 100755 --- a/main/actions/src/main/scala/sbt/ForkTests.scala +++ b/main/actions/src/main/scala/sbt/ForkTests.scala @@ -46,7 +46,11 @@ private[sbt] object ForkTests try { server.accept() } catch { - case _: java.net.SocketException => return + case e: java.net.SocketException => + log.error("Could not accept connection from test agent: " + e.getClass + ": " + e.getMessage) + log.trace(e) + server.close() + return } val os = new ObjectOutputStream(socket.getOutputStream) // Must flush the header that the constructor writes, otherwise the ObjectInputStream on the other end may block indefinitely @@ -55,7 +59,7 @@ private[sbt] object ForkTests try { os.writeBoolean(log.ansiCodesSupported) - + val taskdefs = opts.tests.map(t => new TaskDef(t.name, forkFingerprint(t.fingerprint), t.explicitlySpecified, t.selectors)) os.writeObject(taskdefs.toArray) @@ -91,7 +95,7 @@ private[sbt] object ForkTests acceptorThread.join() Acceptor.result } - + testListeners.foreach(_.doComplete(result.overall)) result } finally {