Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The predicates exposed in https://github.com/apache/jclouds-labs/blob/master/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerApi.java#L183-L197 and other Feature API are not working as expected.
The issue is that where an interface is marked with @Delegate anything that exists inside is considered as something that will be invoked over HTTP. In the case of the Predicates these are not the case. The following error occurs when a call to api.getNetworkApi().networkDomainNormalPredicate().apply(networkDomainId); is made.
Exception in thread "main" java.lang.IllegalStateException: Optional.get() cannot be called on an absent value at com.google.common.base.Absent.get(Absent.java:47) at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:227) at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137) at org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:189) at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:85) at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74) at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45) at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117) at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87) at com.sun.proxy.$Proxy56.networkDomainNormalPredicate(Unknown Source) at org.jclouds.examples.dimensiondata.cloudcontrol.DeployNetworkDomainVlanAndServer.deployNetworkDomain(DeployNetworkDomainVlanAndServer.java:148) at org.jclouds.examples.dimensiondata.cloudcontrol.DeployNetworkDomainVlanAndServer.main(DeployNetworkDomainVlanAndServer.java:78)
The fix is to move the Predicates into org.jclouds.dimensiondata.cloudcontrol.DimensionDataCloudControlApi and remove them from the API classes.
public interface DimensionDataCloudControlApi extends Closeable { @Delegate AccountApi getAccountApi(); @Delegate InfrastructureApi getInfrastructureApi(); @Delegate ServerImageApi getServerImageApi(); @Delegate NetworkApi getNetworkApi(); @Delegate ServerApi getServerApi(); @Delegate TagApi getTagApi(); @Delegate CustomerImageApi getCustomerImageApi(); @Provides @Named(VLAN_DELETED_PREDICATE) Predicate<String> vlanDeletedPredicate(); @Provides @Named(NETWORK_DOMAIN_DELETED_PREDICATE) Predicate<String> networkDomainDeletedPredicate(); @Provides @Named(NETWORK_DOMAIN_NORMAL_PREDICATE) Predicate<String> networkDomainNormalPredicate(); @Provides @Named(VLAN_NORMAL_PREDICATE) Predicate<String> vlanNormalPredicate(); @Provides @Named(SERVER_STOPPED_PREDICATE) Predicate<String> serverStoppedPredicate(); @Provides @Named(SERVER_DELETED_PREDICATE) Predicate<String> serverDeletedPredicate(); @Provides @Named(SERVER_STARTED_PREDICATE) Predicate<String> serverStartedPredicate(); @Provides @Named(SERVER_NORMAL_PREDICATE) Predicate<String> serverNormalPredicate(); }
Fix also requires a change to the https://github.com/apache/jclouds-examples/tree/master/dimensiondata