JCLOUDS-1381: Fix NPE in GCE DiskURIToImage

This commit is contained in:
Ignasi Barrera 2018-02-15 11:55:40 +01:00
parent 50ae6828f5
commit 7aed4bc88c
1 changed files with 4 additions and 2 deletions

View File

@ -45,9 +45,11 @@ public class DiskURIToImage extends CacheLoader<URI, Optional<Image>> {
@Override
public Optional<Image> load(URI key) throws ExecutionException {
try {
Image image = null;
Disk disk = resources.disk(key);
URI sourceImage = disk.sourceImage();
Image image = sourceImage != null ? resources.image(sourceImage) : null;
if (disk != null && disk.sourceImage() != null) {
image = resources.image(disk.sourceImage());
}
return Optional.fromNullable(image);
} catch (Exception e) {
throw new ExecutionException(message(key, e), e);