From 8c3acb2756c7b288ada0bda9143c2d54b2214ed5 Mon Sep 17 00:00:00 2001 From: Timor Morrien Date: Sat, 27 Apr 2024 18:39:57 +0200 Subject: [PATCH] Revert latch removal, as this somehow broke the tests --- .../buildagent/BuildJobContainerService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tum/in/www1/artemis/service/connectors/localci/buildagent/BuildJobContainerService.java b/src/main/java/de/tum/in/www1/artemis/service/connectors/localci/buildagent/BuildJobContainerService.java index ff6d36275a58..fc647c2eb8e8 100644 --- a/src/main/java/de/tum/in/www1/artemis/service/connectors/localci/buildagent/BuildJobContainerService.java +++ b/src/main/java/de/tum/in/www1/artemis/service/connectors/localci/buildagent/BuildJobContainerService.java @@ -13,6 +13,7 @@ import java.nio.file.Paths; import java.time.ZonedDateTime; import java.util.*; +import java.util.concurrent.CountDownLatch; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; @@ -322,6 +323,7 @@ private void executeDockerCommand(String containerId, String buildJobId, boolean execCreateCmd = execCreateCmd.withUser("root"); } ExecCreateCmdResponse execCreateCmdResponse = execCreateCmd.exec(); + final CountDownLatch latch = new CountDownLatch(1); try { dockerClient.execStartCmd(execCreateCmdResponse.getId()).withDetach(detach).exec(new ResultCallback.Adapter<>() { @@ -333,11 +335,20 @@ public void onNext(Frame item) { buildLogsMap.appendBuildLogEntry(buildJobId, buildLogEntry); } } - }).awaitCompletion(); + + @Override + public void onComplete() { + latch.countDown(); + } + }); } catch (ConflictException e) { throw new LocalCIException("Could not execute Docker command: " + String.join(" ", command), e); } + + try { + latch.await(); + } catch (InterruptedException e) { throw new LocalCIException("Interrupted while executing Docker command: " + String.join(" ", command), e); }