okhttp-urlconnection 测试使 mockwebserver 崩溃,但通过了

okhttp-urlconnection test crashes mockwebserver, yet passes

运行 'mvn install' 在 okhttp、okhttp-urlconnection 和 mockwebserver 上,然后 运行 'mvn test' 在 okhttp-urlconnection 中:

Mar 08, 2015 11:53:54 AM com.squareup.okhttp.mockwebserver.MockWebServer execute SEVERE: MockWebServer[51929] connection from /127.0.0.1 crashed java.lang.IllegalStateException: closed at okio.RealBufferedSource.indexOf(RealBufferedSource.java:293) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:289) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196) at com.squareup.okhttp.mockwebserver.MockWebServer.readRequest(MockWebServer.java:555) at com.squareup.okhttp.mockwebserver.MockWebServer.access00(MockWebServer.java:85) at com.squareup.okhttp.mockwebserver.MockWebServer.processOneRequest(MockWebServer.java:482) at com.squareup.okhttp.mockwebserver.MockWebServer.processConnection(MockWebServer.java:444) at com.squareup.okhttp.mockwebserver.MockWebServer.execute(MockWebServer.java:386) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

Mar 08, 2015 11:53:54 AM com.squareup.okhttp.mockwebserver.MockWebServer acceptConnections INFO: MockWebServer[51929] done accepting connections: Socket closed Mar 08, 2015 11:53:54 AM com.squareup.okhttp.mockwebserver.MockWebServer acceptConnections INFO: MockWebServer[51928] done accepting connections: Socket closed Tests run: 109, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.85 sec - in com.squareup.okhttp.UrlConnectionCacheTest

这次崩溃是否是预期结果,因为测试已通过?

这是 MockWebServer 中的一个错误。我们在另一个线程的源和接收器上调用 close(),这是活泼和糟糕的。我来解决。