From 8d819bad97e3e3ed2170f17fbc1ba3d759f5251c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Jackiewicz?= Date: Thu, 25 Apr 2024 10:20:10 +0200 Subject: [PATCH] Prevent deadlock on thread synchronization via CountDownLatch --- .../plugins/kubernetes/pipeline/ContainerExecProc.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecProc.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecProc.java index 291cf09bad..bbfd0ab209 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecProc.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecProc.java @@ -97,8 +97,11 @@ public void kill() throws IOException, InterruptedException { public int join() throws IOException, InterruptedException { try { LOGGER.log(Level.FINEST, "Waiting for websocket to close on command finish ({0})", finished); - finished.await(); - LOGGER.log(Level.FINEST, "Command is finished ({0})", finished); + if (finished.await(1, TimeUnit.MINUTES)) { + LOGGER.log(Level.FINEST, "Command is finished (the count reached zero)"); + } else { + LOGGER.log(Level.FINEST, "Command is finished (waiting time elapsed before the count reached zero)"); + } CompletableFuture exitCodeFuture = watch.exitCode();