Repository: brooklyn-server
Updated Branches:
  refs/heads/master e171d1b41 -> 9b0fe8a6d


JcloudsSshMachineLocation: avoid NPE on rebind


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/b9fc1cc8
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/b9fc1cc8
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/b9fc1cc8

Branch: refs/heads/master
Commit: b9fc1cc85b438c8aeac72959e6f486db2e923c09
Parents: 660ebbb
Author: Aled Sage <aled.s...@gmail.com>
Authored: Mon Mar 28 22:54:23 2016 +0100
Committer: Aled Sage <aled.s...@gmail.com>
Committed: Tue Mar 29 12:06:42 2016 +0100

----------------------------------------------------------------------
 .../location/jclouds/JcloudsSshMachineLocation.java      | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b9fc1cc8/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
----------------------------------------------------------------------
diff --git 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
index ffae5c6..6074eb5 100644
--- 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
+++ 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
@@ -162,8 +162,15 @@ public class JcloudsSshMachineLocation extends 
SshMachineLocation implements Jcl
     @Override
     public void rebind() {
         super.rebind();
-        ComputeServiceContext context = 
jcloudsParent.getComputeService().getContext();
-        runScriptFactory = 
context.utils().injector().getInstance(RunScriptOnNode.Factory.class);
+        
+        if (jcloudsParent != null) {
+            // can be null on rebind, if location has been "orphaned" somehow
+            ComputeServiceContext context = 
jcloudsParent.getComputeService().getContext();
+            runScriptFactory = 
context.utils().injector().getInstance(RunScriptOnNode.Factory.class);
+        } else {
+            LOG.warn("Location {} does not have parent; cannot retrieve 
jclouds compute-service or "
+                    + "run-script factory; later operations may fail 
(continuing)", this);
+        }
         
         if (node != null) {
             setNode(node);

Reply via email to