From 7aed4bc88ccd4748c46bb0fa144ff9185a559e94 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Thu, 15 Feb 2018 11:55:40 +0100 Subject: [PATCH] JCLOUDS-1381: Fix NPE in GCE DiskURIToImage --- .../googlecomputeengine/compute/loaders/DiskURIToImage.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImage.java b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImage.java index 0f98098d08..470cd9eb7c 100644 --- a/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImage.java +++ b/providers/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImage.java @@ -45,9 +45,11 @@ public class DiskURIToImage extends CacheLoader> { @Override public Optional 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);