Skip to content

Commit 69221fe

Browse files
committed
fix(core): fix NPE if latestItem is null in result callback
1 parent 41531ee commit 69221fe

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/main/java/com/github/dockerjava/core/command/BuildImageResultCallback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public String awaitImageId(long timeout, TimeUnit timeUnit) {
6262
}
6363

6464
private String getImageId() {
65-
if (latestItem == null || !latestItem.isBuildSuccessIndicated()) {
65+
if (latestItem == null) {
66+
throw new DockerClientException("Could not build image");
67+
} else if (!latestItem.isBuildSuccessIndicated()) {
6668
throw new DockerClientException("Could not build image: " + latestItem.getError());
6769
} else {
6870
return latestItem.getImageId();

src/main/java/com/github/dockerjava/core/command/PullImageResultCallback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public void awaitSuccess() {
4040
throw new DockerClientException("", e);
4141
}
4242

43-
if (latestItem == null || !latestItem.isPullSuccessIndicated()) {
43+
if (latestItem == null) {
44+
throw new DockerClientException("Could not pull image");
45+
} else if (!latestItem.isPullSuccessIndicated()) {
4446
throw new DockerClientException("Could not pull image: " + latestItem.getError());
4547
}
4648
}

src/main/java/com/github/dockerjava/core/command/PushImageResultCallback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public void awaitSuccess() {
4040
throw new DockerClientException("", e);
4141
}
4242

43-
if (latestItem == null || latestItem.isErrorIndicated()) {
43+
if (latestItem == null) {
44+
throw new DockerClientException("Could not push image");
45+
} else if (latestItem.isErrorIndicated()) {
4446
throw new DockerClientException("Could not push image: " + latestItem.getError());
4547
}
4648
}

0 commit comments

Comments
 (0)