mirror of https://github.com/sbt/sbt.git
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.
This commit is contained in:
parent
6492fa2332
commit
191737d35b
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue