File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
kotlinx-coroutines-nio/src/test/kotlin/kotlinx/coroutines/experimental/nio Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,6 @@ import kotlin.test.assertEquals
1616import kotlin.test.assertTrue
1717
1818class AsyncIOTest {
19- val PORT = Random ().nextInt(10000 ) + 10000 // randomize port for this test
20-
2119 @Rule
2220 @JvmField
2321 val tmpDir = TemporaryFolder ()
@@ -66,7 +64,9 @@ class AsyncIOTest {
6664 val serverChannel =
6765 AsynchronousServerSocketChannel
6866 .open()
69- .bind(InetSocketAddress (PORT ))
67+ .bind(InetSocketAddress (0 ))
68+
69+ val serverPort = (serverChannel.localAddress as InetSocketAddress ).port
7070
7171 val c1 = launch(CommonPool ) {
7272 val client = serverChannel.aAccept()
@@ -83,7 +83,7 @@ class AsyncIOTest {
8383 val connection =
8484 AsynchronousSocketChannel .open()
8585 // async calls
86- connection.aConnect(InetSocketAddress (" 127.0.0.1" , PORT ))
86+ connection.aConnect(InetSocketAddress (" 127.0.0.1" , serverPort ))
8787 connection.aWrite(Charsets .UTF_8 .encode(" OK" ))
8888
8989 val buffer = ByteBuffer .allocate(3 )
You can’t perform that action at this time.
0 commit comments