You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Andrew Phillips <no...@github.com> on 2014/06/24 22:42:21 UTC

Re: [jclouds] Fixed NPE when Server has no Image (JCLOUDS-558) (#421)

> @@ -174,9 +178,15 @@ protected Hardware findHardwareForServerOrNull(ServerInZone serverInZone) {
>     }
>  
>     protected OperatingSystem findOperatingSystemForServerOrNull(ServerInZone serverInZone) {
> -      Image image = findObjectOfTypeForServerOrNull(images.get(), "image", serverInZone.getServer().getImage().getId(),
> -            serverInZone);
> -      return (image != null) ? image.getOperatingSystem() : null;
> +      if (serverInZone.getServer().getImage() != null) {
> +         Image image = findObjectOfTypeForServerOrNull(
> +               images.get(), "image", serverInZone.getServer().getImage().getId(), serverInZone);
> +
> +         return (image != null) ? image.getOperatingSystem() : null;
> +      } else {
> +         return null;
> +      }

[minor] How about
```
Something serverImage = serverInZone.getServer().getImage();
if (serverImage == null) {
   return null;
}
Image image = findObjectOfTypeForServerOrNull(images.get(), "image", serverImage.getId(), serverInZone);
return (image != null) ? image.getOperatingSystem() : null;
```
If this is a backport, this would obviously be something for a separate commit.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/421/files#r14153734