[
https://issues.apache.org/jira/browse/JCLOUDS-1088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15185937#comment-15185937
]
ASF subversion and git services commented on JCLOUDS-1088:
----------------------------------------------------------
Commit fe24698d81bde3f615dd13bed8a0b33c84ebf865 in jclouds-labs's branch
refs/heads/master from [~ladicek]
[ https://git-wip-us.apache.org/repos/asf?p=jclouds-labs.git;h=fe24698 ]
[JCLOUDS-1088] fix NPE in DeploymentToNodeMetadata.apply
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.
> azurecompute: NPE in DeploymentToNodeMetadata.apply
> ---------------------------------------------------
>
> Key: JCLOUDS-1088
> URL: https://issues.apache.org/jira/browse/JCLOUDS-1088
> Project: jclouds
> Issue Type: Bug
> Components: jclouds-labs
> Affects Versions: 1.9.2
> Reporter: Ladislav Thon
> Labels: azurecompute
>
> I'm using the Azure provider {{azurecompute}} from JClouds Labs master and I
> encountered a situation in which {{DeploymentToNodeMetadata.apply}} throws a
> NPE. This is because there's a code like this:
> {code:java}
> final CloudService cloudService = api.getCloudServiceApi().get(from.name());
> if (cloudService != null) {
> builder.location(FluentIterable.from(locations.get()).
> firstMatch(LocationPredicates.idEquals(cloudService.location())).
> orNull());
> }
> {code}
> {{LocationPredicates.idEquals}} throws a NPE if its argument is {{null}}, and
> {{CloudService.location()}} is {{@Nullable}}. The location can easily be
> {{null}} if the cloud service is instead associated with an affinity group.
> Therefore, {{DeploymentToNodeMetadata.apply}} should check if
> {{cloudService.location()}} is {{null}} and if it is, the location should be
> obtained from the affinity group.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)