Skip to content

Commit

Permalink
fix(tagging): NPE if image has no tags
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher committed Feb 26, 2018
1 parent be06733 commit b8ee2ea
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.*;
import java.util.stream.Collectors;

import static java.util.Collections.emptyMap;
import static java.util.stream.Collectors.toMap;

@Component
Expand Down Expand Up @@ -95,7 +96,9 @@ static class AmazonImage implements Comparable<AmazonImage> {
ImageDetails toAmazonImageDetails(String region) {
String imageId = amis.get(region).get(0);

Map<String, String> imageTags = tagsByImageId.get(imageId);
Map<String, String> imageTags = Optional.ofNullable(tagsByImageId)
.map(it -> it.get(imageId))
.orElse(emptyMap());
AppVersion appVersion = AppVersion.parseName(imageTags.get("appversion"));
JenkinsDetails jenkinsDetails = Optional
.ofNullable(appVersion)
Expand Down

0 comments on commit b8ee2ea

Please sign in to comment.