From 8fad77cbece1118361573f8bde66b547d72aadac Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Fri, 2 Feb 2024 10:58:07 -0600 Subject: [PATCH] If BuildImage fails but logs something about success, don't succeed This patch ensures that if the docker build commands result in logging the string "Successfully built", the callback from that build will still fail if there was an error in building. Fixes #2184 --- .../api/command/BuildImageResultCallback.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java b/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java index 331f69509..9db21a6c4 100644 --- a/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java +++ b/docker-java-api/src/main/java/com/github/dockerjava/api/command/BuildImageResultCallback.java @@ -67,14 +67,14 @@ public String awaitImageId(long timeout, TimeUnit timeUnit) { } private String getImageId() { - if (imageId != null) { - return imageId; + if (error != null) { + throw new DockerClientException("Could not build image: " + error); } - if (error == null) { - throw new DockerClientException("Could not build image"); + if (imageId != null) { + return imageId; } - throw new DockerClientException("Could not build image: " + error); + throw new DockerClientException("Could not build image"); } }