我遇到了一个我无法解释的问题...... https://github.com/betehess/play-scalatest的项目正处于孤立状态。
当我运行test
时,sbt会暂停一段时间然后抛出此异常:
> test
[error] Uncaught exception when running tests: java.net.ConnectException: Connection timed out
Exception in thread "Thread-1" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2293)
at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2473)
at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2543)
at java.io.ObjectInputStream$BlockDataInputStream.skipBlockData(ObjectInputStream.java:2445)
at java.io.ObjectInputStream.skipCustomData(ObjectInputStream.java:1941)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:500)
at java.lang.Throwable.readObject(Throwable.java:914)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at sbt.React.react(ForkTests.scala:117)
at sbt.ForkTests$$anonfun$mainTestTask$1$Acceptor$2$.run(ForkTests.scala:76)
at java.lang.Thread.run(Thread.java:745)
看起来sbt卡在https://github.com/sbt/sbt/blob/0.13.5/main/actions/src/main/scala/sbt/ForkTests.scala#L117的分叉环境的阻塞调用中。
一些评论:
build.sbt
答案 0 :(得分:3)
我终于知道发生了什么。
事实证明,在正确的设置下,sbt将分叉JVM来执行测试,并希望与它进行通信。如何做到这一点取决于测试框架。在scalatest的情况下,两个进程之间的通信将通过服务器完成。 scalatest只传达sbt必须使用的服务器地址和端口。这种情况正在发生there。
val array = Array(InetAddress.getLocalHost.getHostAddress, skeleton.port.toString)
现在,请阅读javadoc对InetAddress#getLocalHost所说的内容:
返回本地主机的地址。这是通过检索来实现的 系统中主机的名称,然后将该名称解析为 的InetAddress。
我在Linux上。我的本地主持人(从不 localhost
)最终成为dopey
。现在,出于某种原因(我在家里弄乱了我的网络),我的/etc/hosts
正在为dopey
分配一个虚假地址。因此,而不是127.0.0.1
之类的东西,scalatest会尝试在这个虚构的服务器上打开一个套接字。由于where this is happening,您在堆栈跟踪中看不到任何有用的内容。
我的猜测是,意图总是使用127.0.0.1
...