Skip to content

Commit 6d15d72

Browse files
committed
don't block the thread when waiting for TCP port
1 parent d8d34e7 commit 6d15d72

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/main/groovy/com/avast/gradle/dockercompose/ComposeExtension.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ComposeExtension {
1919
boolean waitForTcpPorts = true
2020
Duration waitAfterTcpProbeFailure = Duration.ofSeconds(1)
2121
Duration waitForTcpPortsTimeout = Duration.ofMinutes(15)
22-
Duration waitForTcpPortsDisconnection = Duration.ofMillis(1000)
22+
Duration waitForTcpPortsDisconnectionProbeTimeout = Duration.ofMillis(1000)
2323
Duration waitAfterHealthyStateProbeFailure = Duration.ofSeconds(5)
2424
Duration waitForHealthyStateTimeout = Duration.ofMinutes(15)
2525
List<String> useComposeFiles = []

src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,11 @@ class ComposeUp extends DefaultTask {
193193
while (true) {
194194
try {
195195
def s = new Socket(service.host, forwardedPort)
196-
s.setSoTimeout(1)
196+
s.setSoTimeout(extension.waitForTcpPortsDisconnectionProbeTimeout.toMillis() as int)
197197
try {
198198
// in case of Windows and Mac, we must ensure that the socket is not disconnected immediately
199199
// if the socket is closed then it returns -1
200-
// if the socket is not closed then returns a data or timeouts (the timeout is set to 1ms)
201-
Thread.sleep(extension.waitForTcpPortsDisconnection.toMillis())
200+
// if the socket is not closed then returns a data or timeouts
202201
boolean disconnected = false
203202
try {
204203
disconnected = s.inputStream.read() == -1

0 commit comments

Comments
 (0)