From 0e41b45af598576821084c5bff2c54342ff860c6 Mon Sep 17 00:00:00 2001 From: Sergey Tselovalnikov Date: Tue, 17 May 2016 14:39:44 +0300 Subject: [PATCH] Fix NPE when node is null --- .../impl/AdaptingComputeServiceStrategies.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index db24331f04..da3874751c 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -144,21 +144,22 @@ public class AdaptingComputeServiceStrategies implements CreateNodeW @Override public NodeMetadata rebootNode(String id) { NodeMetadata node = getNode(checkNotNull(id, "id")); - checkStateAvailable(node); + checkStateAvailable(id, node); client.rebootNode(id); // invalidate state of node return getNode(checkNotNull(id, "id")); } - private void checkStateAvailable(NodeMetadata node) { - checkState(node != null && node.getStatus() != Status.TERMINATED, + private void checkStateAvailable(String id, NodeMetadata node) { + checkState(node != null, "node with id %s terminated or unavailable!", id); + checkState(node.getStatus() != Status.TERMINATED, "node %s terminated or unavailable! current status: %s", node, formatStatus(node)); } @Override public NodeMetadata resumeNode(String id) { NodeMetadata node = getNode(checkNotNull(id, "id")); - checkStateAvailable(node); + checkStateAvailable(id, node); client.resumeNode(id); // invalidate state of node return getNode(checkNotNull(id, "id")); @@ -167,7 +168,7 @@ public class AdaptingComputeServiceStrategies implements CreateNodeW @Override public NodeMetadata suspendNode(String id) { NodeMetadata node = getNode(checkNotNull(id, "id")); - checkStateAvailable(node); + checkStateAvailable(id, node); client.suspendNode(id); // invalidate state of node return getNode(checkNotNull(id, "id"));