File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ jobs:
186
186
shell : bash
187
187
run : |
188
188
# test building sbtn on Windows
189
+ sbt "commandProj/testOnly xsbt.IPCSpec"
189
190
sbt "-Dsbt.io.virtual=false" nativeImage
190
191
# test launcher script
191
192
echo build using JDK 8, test using JDK 8, on Windows
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ object IPC {
17
17
private val portMin = 1025
18
18
private val portMax = 65536
19
19
private val loopback = InetAddress .getByName(null )
20
+ private [xsbt] val socketBacklog = 50 // 50 is the default backlog size for the java.net.Socket
20
21
21
22
def client [T ](port : Int )(f : IPC => T ): T = ipc(new Socket (loopback, port))(f)
22
23
@@ -34,7 +35,7 @@ object IPC {
34
35
35
36
def createServer (attempts : Int ): ServerSocket =
36
37
if (attempts > 0 ) {
37
- try new ServerSocket (nextPort, 1 , loopback)
38
+ try new ServerSocket (nextPort, socketBacklog , loopback)
38
39
catch { case NonFatal (_) => createServer(attempts - 1 ) }
39
40
} else sys.error(" Could not connect to socket: maximum attempts exceeded" )
40
41
Original file line number Diff line number Diff line change
1
+ /*
2
+ * sbt
3
+ * Copyright 2011 - 2018, Lightbend, Inc.
4
+ * Copyright 2008 - 2010, Mark Harrah
5
+ * Licensed under Apache License 2.0 (see LICENSE)
6
+ */
7
+
8
+ package xsbt
9
+
10
+ import org .scalatest .flatspec .AnyFlatSpec
11
+ import org .scalatest .matchers .should .Matchers ._
12
+
13
+ class IPCSpec extends AnyFlatSpec {
14
+ " server" should " allow same number of connections as determined in socket backlog" in {
15
+ noException should be thrownBy {
16
+ val server = IPC .unmanagedServer
17
+ (1 until IPC .socketBacklog + 1 ).foreach { _ =>
18
+ IPC .client(server.port)(identity)
19
+ }
20
+ server.close()
21
+ }
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments