You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Ladislav Thon <no...@github.com> on 2016/03/02 15:32:16 UTC

[jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

The NPE is caused by passing the value of `CloudService.location()` to `LocationPredicates.idEquals` which throws a NPE when the argument is `null`. However, `CloudService.location()` is `@Nullable` and is `null` when the cloud service is associated with an affinity group.

The solution in this commit checks if `CloudService.location()` is `null` and if it is, the location is obtained from the affinity group.

Fixes https://issues.apache.org/jira/browse/JCLOUDS-1088
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/243

-- Commit Summary --

  * [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply

-- File Changes --

    M azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java (6)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/243.patch
https://github.com/jclouds/jclouds-labs/pull/243.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ignasi Barrera <no...@github.com>.
Closed #243.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243#event-582433055

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ignasi Barrera <no...@github.com>.
Thanks @Ladicek! (FYI the build has failed due to a checkstyle error: [unused import](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/1054/org.apache.jclouds.labs$azurecompute/violations/file/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java/)).

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243#issuecomment-191262639

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ignasi Barrera <no...@github.com>.
Pushed to master as [fe24698d](http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/fe24698d). Thanks @Ladicek!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243#issuecomment-193990786

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ignasi Barrera <no...@github.com>.
The change lgtm. @andreaturli ?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243#issuecomment-191271760

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ladislav Thon <no...@github.com>.
Aww, sorry about that checkstyle error. Should be fixed now.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/243#issuecomment-191264773

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ignasi Barrera <no...@github.com>.
> @@ -117,8 +118,11 @@ public NodeMetadata apply(final Deployment from) {
>        // TODO: CloudService name is required (see JCLOUDS-849): waiting for JCLOUDS-853.
>        final CloudService cloudService = api.getCloudServiceApi().get(from.name());
>        if (cloudService != null) {
> +         final String location = cloudService.location() != null
> +                 ? cloudService.location()
> +                 : api.getAffinityGroupApi().get(cloudService.affinityGroup()).location();

The affinityGroup field is also marked `@Nullable`, is it always present when the location field is missing?
Also, the AffinityGroupApi.get method returns null if the affinity group is not found. Should we protect the code against this case?

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

Re: [jclouds-labs] [JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply (#243)

Posted by Ladislav Thon <no...@github.com>.
> @@ -117,8 +118,11 @@ public NodeMetadata apply(final Deployment from) {
>        // TODO: CloudService name is required (see JCLOUDS-849): waiting for JCLOUDS-853.
>        final CloudService cloudService = api.getCloudServiceApi().get(from.name());
>        if (cloudService != null) {
> +         final String location = cloudService.location() != null
> +                 ? cloudService.location()
> +                 : api.getAffinityGroupApi().get(cloudService.affinityGroup()).location();

Well, to be absolutely honest, I'm not sure -- but the `CloudService` javadoc suggests that these two are mutually exclusive.

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