Repository: incubator-brooklyn Updated Branches: refs/heads/master 5dd08aa11 -> d84630eee
Fix NPE when jclouds image does not have OsFamily Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/892823d3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/892823d3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/892823d3 Branch: refs/heads/master Commit: 892823d3e6b86c77e37fc89fceb8c3c198565c4a Parents: 5dd08aa Author: Aled Sage <[email protected]> Authored: Wed Jun 3 11:27:42 2015 +0200 Committer: Aled Sage <[email protected]> Committed: Wed Jun 3 11:27:42 2015 +0200 ---------------------------------------------------------------------- .../java/brooklyn/location/jclouds/JcloudsLocation.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/892823d3/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java ---------------------------------------------------------------------- diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java index 34de383..23b79ed 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java @@ -1290,11 +1290,13 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im // Finally try to build the template Template template; + Image image; try { template = templateBuilder.build(); if (template==null) throw new NullPointerException("No template found (templateBuilder.build returned null)"); - LOG.debug("jclouds found template "+template+" (image "+template.getImage()+") for provisioning in "+this+" for "+config.getDescription()); - if (template.getImage()==null) throw new NullPointerException("Template does not contain an image (templateBuilder.build returned invalid template)"); + image = template.getImage(); + LOG.debug("jclouds found template "+template+" (image "+image+") for provisioning in "+this+" for "+config.getDescription()); + if (image==null) throw new NullPointerException("Template does not contain an image (templateBuilder.build returned invalid template)"); } catch (AuthorizationException e) { LOG.warn("Error resolving template: not authorized (rethrowing: "+e+")"); throw new IllegalStateException("Not authorized to access cloud "+this+" to resolve "+templateBuilder, e); @@ -1319,7 +1321,8 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im } TemplateOptions options = template.getOptions(); - if (template.getImage().getOperatingSystem().getFamily().equals(OsFamily.WINDOWS)) { + OsFamily osFamily = (image.getOperatingSystem() != null) ? image.getOperatingSystem().getFamily() : null; + if (OsFamily.WINDOWS == osFamily) { if (!(config.containsKey(JcloudsLocationConfig.USER_METADATA_STRING) || config.containsKey(JcloudsLocationConfig.USER_METADATA_MAP))) { config.put(JcloudsLocationConfig.USER_METADATA_STRING, WinRmMachineLocation.getDefaultUserMetadataString()); }
