properly cleanup selector in tests

This commit is contained in:
Johannes Rudolph 2013-01-22 11:41:40 +01:00
parent 3687697aed
commit a53848edfa

View file

@ -390,6 +390,8 @@ class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms")
if (nioSelector.selectedKeys().contains(serverSelectionKey)) tryReading() if (nioSelector.selectedKeys().contains(serverSelectionKey)) tryReading()
else 0 else 0
nioSelector.selectedKeys().clear()
pullFromServerSide(remaining - read, remainingTries - 1) pullFromServerSide(remaining - read, remainingTries - 1)
} }
@ -397,7 +399,9 @@ class TcpConnectionSpec extends AkkaSpec("akka.io.tcp.register-timeout = 500ms")
buffer.clear() buffer.clear()
val read = serverSideChannel.read(buffer) val read = serverSideChannel.read(buffer)
if (read == -1) if (read == 0)
throw new IllegalStateException("Made no progress")
else if (read == -1)
throw new IllegalStateException("Connection was closed unexpectedly with remaining bytes " + remaining) throw new IllegalStateException("Connection was closed unexpectedly with remaining bytes " + remaining)
else read else read
} }