Skip to content

Commit 6e8a92c

Browse files
committed
Randomize port for AsyncIOTest
1 parent 91d5ea9 commit 6e8a92c

File tree

1 file changed

+5
-2
lines changed
  • kotlinx-coroutines-nio/src/test/kotlin/kotlinx/coroutines/experimental/nio

1 file changed

+5
-2
lines changed

kotlinx-coroutines-nio/src/test/kotlin/kotlinx/coroutines/experimental/nio/AsyncIOTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import java.nio.channels.AsynchronousFileChannel
1111
import java.nio.channels.AsynchronousServerSocketChannel
1212
import java.nio.channels.AsynchronousSocketChannel
1313
import java.nio.file.StandardOpenOption
14+
import java.util.*
1415
import kotlin.test.assertEquals
1516
import kotlin.test.assertTrue
1617

1718
class AsyncIOTest {
19+
val PORT = Random().nextInt(10000) + 10000 // randomize port for this test
20+
1821
@Rule
1922
@JvmField
2023
val tmpDir = TemporaryFolder()
@@ -63,7 +66,7 @@ class AsyncIOTest {
6366
val serverChannel =
6467
AsynchronousServerSocketChannel
6568
.open()
66-
.bind(InetSocketAddress(8080))
69+
.bind(InetSocketAddress(PORT))
6770

6871
val c1 = launch(CommonPool) {
6972
val client = serverChannel.aAccept()
@@ -80,7 +83,7 @@ class AsyncIOTest {
8083
val connection =
8184
AsynchronousSocketChannel.open()
8285
// async calls
83-
connection.aConnect(InetSocketAddress("127.0.0.1", 8080))
86+
connection.aConnect(InetSocketAddress("127.0.0.1", PORT))
8487
connection.aWrite(Charsets.UTF_8.encode("OK"))
8588

8689
val buffer = ByteBuffer.allocate(3)

0 commit comments

Comments
 (0)